2

Recently, I started working on a CentOS server and got access via ssh. I have root privilege through ssh. How can I download a file from server into my PC and upload to another server through ssh?

2
  • For one file it won't matter, but using rsync has many advantages over scp. – pfnuesel May 29 '17 at 12:22
  • I noted. Thanks you rsync – Rei Jun 5 '17 at 14:21
3

Use scp command to upload a file:

scp [local-path] [username]@[hostname/ip]:[remote-path]
example:

scp /etc/example.file user@example.com:/etc/example
scp /etc/passwd user@10.0.0.1:/etc/passwd 

To download a file:
1. You have a webserver installed on your server. Place your file under website's root directory

example:

website:http://example.com

remote file location: /webroot/example.file

wget http://example.com/example.file

2. No webserver installed

scp [username]@[hostname/ip]:[remote-path] [localpath]

example:

scp user@example.com:/etc/passwd ./passwd
scp user@10.0.0.1:/etc/passwd ./passwd

IF you use iTerm2,it uses an awesome way to handle file upload/download through ssh client with a single right click: see here:iTerm2-shell-integration

1
  • Thanks you so much I used scp. scp root@example.com:[folder,path,etc..] ~/Downloads It's syntax download into folder Downloads in PC And easy to upload to another server. – Rei May 30 '17 at 3:36
1

scp is what are you looking for.

Copy file from remote host (example.com) to ~/Downloads on your computer

scp root@example.com:/tmp/file ~/Downloads

.. and from your computer to a remote host (into home dir)

scp /tmp/file root@example.com:~/
1
  • I used scp. winscp is really nice tool – Rei Jun 23 '17 at 12:36

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