Ssh-keygen
From Hackepedia
Jump to navigationJump to search
I choose to generate RSA over DSA keys, and I choose 2048 bits instead of the default 1024. Read the Manual for more options.
$ ssh-keygen -t rsa -b 2048 Generating public/private rsa key pair. Enter file in which to save the key (/home/yashy/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/yashy/.ssh/id_rsa. Your public key has been saved in /home/yashy/.ssh/id_rsa.pub. The key fingerprint is: 8f:31:0a:4f:0d:35:87:2b:b8:7b:95:6b:f4:c0:3a:3b yashy@help
Being aware of the security risks, I just enter [Enter] both times it asked me to enter a passphrase, I now I have no passphrase on this key. Once this was completed, I did:
$ cat /home/yashy/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAABromanEA6My5JCmMJX0EoaHX9R7ZE5KQZ7dKxdfirsttQaUx5wMlnweF6MLWbU2tzJ1aZMr8jyL7e+empireB52ZKNDhs1amr8X6+e/L9UQX8OKKzcZyUj8rO8QTdw+vsgk8IQbiMO1GYYWVHw9HO0lYUmZTWFGTe0rSRu/mSRuNpsoVO80nWNbnP0wUa0YrGPyPMIoyIpo/BKUpSjHUSLUiC7KuSsDmVxMFuanvYsx79yx0KjRmXn73AdbH+VzSdlhC/5GIFnqbY2eZ6PeNmhAAspya62Wsc4caSrdE85Kp/TMwUZB4yF90VBG7mJjL+HZSIiO5irIM2HXDZaMVZe+iS5DoboEYaiA7DJuatR9KZ8+JeQ== yashy@help
Now I take that one really long line and copy it, and paste it into the remote host as a file called /home/yashy/.ssh/authorized_keys. Once I've done that, I can now ssh to the remote host doing a key exchange instead of entering a password. Unless you're aware of the risks, you're a lot safer to have entered a password during the key generation process. Enjoy!