How to download a file from server using SSH?
I need to download a file from server to my desktop. (UBUNTU 10.04) I don't have a web access to the server, just ssh.
If it helps, my OS is Mac OS X and iTerm 2 as a terminal.
In your terminal, type:
scp [email protected]:foobar.txt /local/dir
replacing the username, host, remote filename, and local directory as appropriate.
If you want to access EC2 (or other service that requires authenticating with a private key), use the
scp -i key_file.pem [email protected]:/remote/dir/foobar.txt /local/dir
Read more... Read less...
You can do this with the
scp uses the SSH protocol to copy files across system by extending the syntax of
Copy something from another system to this system:
scp [email protected]:/path/to/remote/file /path/to/local/file
Copy something from this system to some other system:
scp /path/to/local/file [email protected]:/path/to/remote/file
Copy something from some system to some other system:
scp [email protected]:/path/to/file [email protected]:/path/to/other/file
scp is certainly the way to go, but for completeness you can also do:
$ ssh host 'cat /path/on/remote' > /path/on/local
$ cat /path/on/local | ssh host 'cat > /path/on/remote'
Note, this is UUOC, but
< /path/on/local ssh host 'cat > /path' could cause unnecessary confusion.
And to proxy between two hosts:
$ ssh host1 'cat /path/on/host1' | ssh host2 'cat > /path/on/host2'