Login to openhabian(or other linux) Automagically with no password!

Hello All! I login in and out many times per day since I am in the process of building my openhab2 system. I wanted to post a shortcut that I did. This shortcut will allow you to avoid entering the password and auto login. I used cygwin on windows as my terminal, but this will work if you are using Linux or another terminal server. See note below if using Putty on windows.

  1. If on Windows, install cygwin with SSH

  2. Login to the opehab server to get the initial known host file setup using “ssh openhabuser@openhabserver”, then logout back to local shell

  3. execute “ssh-keygen -t rsa” on localhost to generate a key pair. Just click enter taking default settings and set no passphrase.

  4. Copy the newly generated keys to the openhab server using the command “ssh-copy-id -i ~/.ssh/id_rsa.pub openhabuser@openhabserver”

  5. Try to login using “ssh openhabuser@openhabserver” you should auto login with no password.

  6. Once logged in execute “chmod 700 .ssh; chmod 640 .ssh/authorized_keys” from the command line to set the proper file permissions"

Supporting Links:
https://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id
https://www.ssh.com/ssh/keygen/
https://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/

****Note:**If you are using Putty on windows this can be done using PuTTYgen, however this tutorial does not fully cover that setup process. Please see: https://www.ssh.com/ssh/putty/windows/puttygen#sec-Running-PuTTYgen

3 Likes

You can run the ssh-keygen command on the RPi and copy the certs from the RPi to the local host as well.

It really doesn’t matter where the certs are generated so long as the match on both machines.

@rlkoshak Thanks for reminding me of this, I had forgotten that point. Using this allowed me to quickly setup putty also. Years ago, I knew I remembered using my remote server to generate the keys vs my post using the local host.

I need to edit the original post to include this note as it is very good info to have.

Thanks!