SSH

Key Management

Generate new key:

ssh-keygen -f $HOME/.ssh/id_[name] -C "[comment]"

Deploy key to host:

ssh-copy-id -i $HOME/.ssh/id_[name] [username]@[hostname]

Change key passphrase:

ssh-keygen -p -f $HOME/.ssh/id_[name]

Output public key from private key:

ssh-keygen -y -f [key] > [key.pub]

Client Configuration

Use the following example to create your $HOME/.ssh/config configuration file:

##########
# Global #
##########
AddKeysToAgent yes
IdentityFile ~/.ssh/id_mainkey


#########
# Hosts #
#########
Host server1
    HostName server1.example.org
    User root

Jump Host

ssh -J <user>@<jumphost> <user>@<destination>

This can also be achieved using the ProxyJump configuration directive:

Host destination
    ProxyJump <user>@<jump>
    HostName <destination>
    User <user>