13. SSH

13.1. Generate Key

  • ssh-keygen

  • Add comment

  • ~/.id_rsa

  • ~/.id_rsa.pub

13.2. Connect

  • ssh -i myprivatekey.pem -l myuser myhost

13.3. Authorized Keys

  • Comments

13.4. Known Hosts

13.5. Port Forwarding

  • Reverse Tunnel

  • -L

  • -R

13.6. Config and Host Aliases

  • ~/.ssh/config

Host myhost1
    HostName 10.13.37.1
    Port 22
    User myuser

Host myhost2
    HostName 10.13.37.2
    Port 22
    User myuser
    LocalForward 3000 127.0.0.1:3000
    LocalForward 8083 127.0.0.1:8083
    LocalForward 8084 127.0.0.1:8084
    IdentityFile ~/.id_rsa

Host *
    ServerAliveInterval 30
    ServerAliveCountMax 2

13.7. SSHd

  • Disabling password authentication

  • /etc/ssh/ssh_config

  • sudo service sshd restart