Categories
IT-Stuff

4 Step Setup SSH Login without password

Quick 4 Steps on howto ssh login without a password

A quick and dirty version of how it’s done.

Disclaimer:
use this code at your own risk and only if you know what you are doing. no liability from us for the consequences. so leave us alone if things go sideways

Step 1 (check if there is any existing key)

ls -al ~/.ssh/id_*.pub

Step 2 (if you find nothing) go and generate a new pair of SSH keys (the keys will be stored in the users /home look for something like .ssh/id_rsa If you found some in Step 1 head up to Step 3

ssh-keygen -t rsa -b 4096 -C "your-mail@domain.com"

Thinking of an extra layer of security enter a password, if no use for that in your use case hit enter (2x) after that, check with ls ~/.ssh/id_* if the key is there, this is gonna look something like .ssh/id_rsa.pub and ./ssh/id_rsa in your users home directory

Step 3 Copy the public key (use ssh-copy) to the remote host. While this is gonna happen you will be prompted to enter the password for the remote username (on the remote host) of the ssh key. Once the user is authenticated, the public key will be appended to the remote user authorized_keys file and the connection will be closed. Just a side note you can add the same key to multiple remote serves.

ssh-copy-id remote_username@remote_server_ip_address

Step 4 ssh in the remote server using ssh keys

ssh remote_username@remote_server_ip_address

If that all comes together well, you will be logged in immediately
Enjoy and have Fun !

PS:
If for some reason, ssh-copy is not working, you can try this at your own risk, but its is highly recommended to user ssh-copy.

cat ~/.ssh/id_rsa.pub | ssh remote_user@remote-server "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

Thats all folks !

This article can be also used with disabling-ssh-password-authentication