currently logged onto my remote server.. how do I transfer file from my local machine to my remote server using SCP

1

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@147.144.12.15:.

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

ahsw

Posted 2017-09-04T05:51:25.940

Reputation: 13

Answers

0

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@147.144.12.15:~

Note:-

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

nagendra547

Posted 2017-09-04T05:51:25.940

Reputation: 116

1OK. 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 – 2017-09-04T06:39:12.733

Yes, right. Open a new terminal on your local machine and use scp command to copy files on remote. – nagendra547 – 2017-09-04T06:42:02.257

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: https://unix.stackexchange.com/questions/188285/how-to-copy-a-file-from-a-remote-server-to-a-local-machine

– jnL – 2017-09-04T06:50:36.287

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! – nagendra547 – 2017-09-04T08:18:28.830

0

You can even use rsync

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

Flags

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

Vishal Shinde

Posted 2017-09-04T05:51:25.940

Reputation: 31

But note that "local" is the machine you do the command on. "Remote" is the other. – WGroleau – 2017-09-04T07:29:06.943