| Command | Description |
|---|---|
ssh user@host |
Connect to a remote machine |
ssh user@host -p 2222 |
Connect on a specific port |
ssh-keygen |
Generate a new SSH key pair |
ssh-copy-id user@host |
Copy your key to a server (no more passwords) |
ssh -i ~/.ssh/mykey user@host |
Connect using a specific key |
scp file.txt user@host:~/ |
Copy a file to a remote machine |
scp user@host:~/file.txt . |
Copy a file from a remote machine |
scp -r folder/ user@host:~/ |
Copy a folder to a remote machine |
ssh -L 8080:localhost:80 user@host |
Forward local port to remote (tunnel) |
exit |
Disconnect from the remote machine |
Keys go in ~/.ssh/ ยท Config file at ~/.ssh/config saves typing
~/.ssh/config example: Host myserver โ HostName 192.168.1.10, User bee