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?
Asked
Active
Viewed 2.2k times
1
-
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](https://www.server-world.info/en/note?os=CentOS_7&p=rsync) – Rei Jun 05 '17 at 14:21
2 Answers
4
Use scp command to upload a file:
scp [local-path] [username]@[hostname/ip]:[remote-path]
example:
scp /etc/example.file [email protected]:/etc/example
scp /etc/passwd [email protected]:/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 [email protected]:/etc/passwd ./passwd
scp [email protected]:/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
FrontENG
- 263
- 1
- 11
-
Thanks you so much I used scp. scp [email protected]:[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 03:36
0
scp is what are you looking for.
Copy file from remote host (example.com) to ~/Downloads on your computer
scp [email protected]:/tmp/file ~/Downloads
.. and from your computer to a remote host (into home dir)
scp /tmp/file [email protected]:~/
stderr
- 976
- 4
- 12