Requirement
- your ssh pub key had added to remote server’s ~/.ssh/authorized_keys file
copy from remote server
if your remote server use default port
22
to connect ssh, Just execute this command:1
2
3scp user@remote_host:foo.txt /local/dir
like:
scp root@123.123.1.123:/home/root/Desktop/test.sql ~/Desktop/sql/if your remote server specify other port like
12345
as ssh port, use- P
parameter execute this command:1
2
3scp -P [port] user@remote_host:foo.txt /local/dir
like:
scp -P 12345 root@123.123.1.123:/home/root/Desktop/test.sql ~/Desktop/sql/
copy file to remote server
- copy local file to remote ssh server:
1
2
3scp /dir/foo.txt user@remote_host:/home/name/dir
like:
scp ~/Desktop/sql/foo.sql root@123.123.1.123:/home/root/Desktop/
Attention:
when you use ssh command connect remote server, you use lowwer case
- p
:1
ssh -p user@remote_host
but when you use scp command, you must use upper case
- P
1
ssh -P user@remote_host