Category Archives: SSH
All about SSH
First you have to create a public, private key pair. For this you can use the command-line tool sshkey-gen.
Change the directory to “~/.ssh” (create it, if it does not exist).
Create key pair
Now let’s create the key pair. In this example I will use RSA with 4096 Bit
ssh-keygen -t rsa -b 4096
Enter a passphrase if you want but you don’t have to. I recommend to enter a passphrase.
Transfer public key to ssh server
To transfer the public key to the ssh server you can use ssh-copy-id.
ssh-copy-id -i ~/.ssh/id_rsa.pub HOST
Login with key
Now you should be able to login with the created key.
Linux saves the ssh host keys in ~/.ssh/known_hosts. You can manage these ssh host keys with the command ssh-keygen.
Search for a specific host (in known_hosts):
ssh-keygen -F HOSTNAME
Remove a specific host:
ssh-keygen -R HOSTNAME
To add a new ssh host key you can use ssh-keyscan. This command print the ssh host key on the stdout. So we have to append this key to the known_hosts file.
ssh-keyscan -H HOSTNAME >> ~/.ssh/known_hosts