$ ssh-copy-id user@server
Copy to alias server
$ ssh-copy-id server1
Copy specific key
$ ssh-copy-id -i ~/.ssh/id\_rsa.pub user@server
$ ssh-copy-id user@server
Copy to alias server
$ ssh-copy-id server1
Copy specific key
$ ssh-copy-id -i ~/.ssh/id\_rsa.pub user@server
$ ssh -J proxy\_host1 remote\_host2
$ ssh -J user@proxy\_host1 user@remote\_host2
Multiple jumps
$ ssh -J user@proxy\_host1:port1,user@proxy\_host2:port2 user@remote\_host3
Host server1
HostName 192.168.1.5
User root
Port 22
IdentityFile ~/.ssh/server1.key
Launch by alias
$ ssh server1
See: Full Config Options
Options | Description |
---|---|
scp -r |
Recursively copy entire directories |
scp -C |
Compresses data |
scp -v |
Prints verbose info |
scp -P 8080 |
Uses a specific Port |
scp -B |
Batch mode (Prevents password) |
scp -p |
Preserves times and modes |
File Path | Description |
---|---|
/etc/ssh/ssh_config |
System-wide config |
~/.ssh/config |
User-specific config |
~/.ssh/id_{type} |
Private key |
~/.ssh/id_{type}.pub |
Public key |
~/.ssh/known_hosts |
Logged in host |
~/.ssh/authorized_keys |
Authorized login key |
Copies from remote to local
$ scp user@server:/dir/file.ext dest/
Copies between two servers
$ scp user@server:/file user@server:/dir
Copies from local to remote
$ scp dest/file.ext user@server:/dir
Copies a whole folder
$ scp -r user@server:/dir dest/
Copies all files from a folder
$ scp user@server:/dir/\* dest/
Copies from a server folder to the current folder
$ scp user@server:/dir/\* .
Executes remote command
$ ssh [[email protected]](/cdn-cgi/l/email-protection) 'ls -l'
Invoke a local script
$ ssh [[email protected]](/cdn-cgi/l/email-protection) bash < script.sh
Compresses and downloads from a server
$ ssh [[email protected]](/cdn-cgi/l/email-protection) "tar cvzf - ~/source" > output.tgz
Connect to a server (default port 22)
$ ssh [[email protected]](/cdn-cgi/l/email-protection)
Connect on a specific port
$ ssh [[email protected]](/cdn-cgi/l/email-protection) -p 6222
Connect via pem file (0400 permissions)
$ ssh -i /path/file.pem [[email protected]](/cdn-cgi/l/email-protection)
See: SSH Permissions