I'm currently logged onto my remote server and I need to transfer a file from my local machine to my remote server using SCP but it doesn't seem to be working. I was able to do it using SFTP but I don't know why I am having such a difficult time with using SCP.

[awong10@hills ~]$ scp -r ~/sugar.txt awong10@

this is the command I entered but apparently it's wrong. am I missing something?

2 Answers 2


You need to use the scp command from your local box.

I assume, ssh server is running on remote box.

scp -r <File/Folder> username@remoteServerIP:<dirNameToCopy>

So this should work fine. It will copy ~/sugar.txt from your localbox to your remote server in home directory of awong10 user

   scp -r ~/sugar.txt awong10@


-r option is not needed as such for copying a single file. If you want to copy whole folder then use -r

  • 1
    OK. so I would need to open a new terminal and use the scp command from my local machine home directory, correct? I've been using the scp command on my remote machine directory which I ssh'd into.
    – ahsw
    Sep 4, 2017 at 6:39
  • Yes, right. Open a new terminal on your local machine and use scp command to copy files on remote. Sep 4, 2017 at 6:42
  • You don't have to be on your local machine, if you can connect to it from your remote server. Just use scp like this: scp user@localbox:/file/source ~/destination to copy /file/source from remote server (your local box) to your "local" server, where you ssh'd into. Also see: unix.stackexchange.com/questions/188285/…
    – jnL
    Sep 4, 2017 at 6:50
  • That's another option. But copying files- login to remote and then copy file from local to remote is not a good way. You need to install and setup ssh server on your local machine also and why you would do that, if remote machine is already having ssh running! Sep 4, 2017 at 8:18

You can even use rsync

rsync [flags] [local path] [user]@[remote server]:[remote path]


r – Recursive

l – Transfer any symlinks encountered

t – Preserve time stamps

p – Preserve permissions

g – Preserve groups

o – Preserve ownership

D – Preserve block and character devices

You may want to add the following to your command for easier to read file sizes:

h – Human-readable format of file sizes
  • But note that "local" is the machine you do the command on. "Remote" is the other.
    – WGroleau
    Sep 4, 2017 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.