scp
scp [-r] <source> <target>
The scp command allows you to transfer files or directories securely between a local and a remote host (or between two remote hosts).
- From Local to Remote (upload):
1
2
3
4
5
| # transfer a dirctory
scp -r ./example_dir 192.168.0.10:/root
# transfer a single file
scp ./example_file.md 192.168.0.10:/root
|
- From Remote to Local (download):
Of course, you can also transfer files from a remote host to your local machine:
1
2
3
4
5
| # download a directory
scp -r 192.168.0.10:/root/example_dir /root
# download a single file
scp 192.168.0.10:/root/example_file.md /root
|
ssh
ssh [-L/R <local_port>:<target_host>:<target_port>] <user@ssh_server>
The ssh(Secure Shell) command is used to log in to remote server or to set up “port forwarding”. Port forwarding allows you to securely transfer data between your local machine and a remote server by tunneling traffic through the SSH connection.
- Log in to Remote Server
- Local Port Forward
This command can transfer data from your local port(8080) to remote port(192.168.0.10:80).If the target host is the SSH server itself, you can use localhost as the target address.
- Remote Port Forward
This command forwards traffic from a remote port(8080) back to local port(80) on your machine. This is useful for making a local service accessible to the remote server.