Here I am going to explain, how to enable Key and Password based authentication in linux instances of Google Cloud. This can be applied on other Cloud or standalone Linux instances. But do check manuals 🙂
When i say Key + Password, I am not referring passphrase which we give while created Private/Publich SSH key. I am referring to multiple auth methods where system will be first authenticated via PubKey and then via Password.
If your Pubkey is not matching it won’t allow you to login. If password not matching then also it won’t allow you to login. You must use exact same credentials which you configured.
I am not explaining here how to create SSH keys or password, I am assuming you already know that.
In order to enable key + password. You have to update below file as root
/etc/ssh/sshd_config
In this file you have to specify Authentication methods and there sequence by adding below line if not exist:
AuthenticationMethods publickey, password
Also in Google Cloud by default password authentication is off so you have to enable it by changing “PasswordAuthentication” to “yes”, to allow ssh password authentication.
Don’t forget to set password for your user if you using default user because Google Cloud Platform not set password by default use “sudo password [username]” to set the same.
Once you made these changes, you will need to restart your sshd service using below command.
sudo service ssh restart
And you are all done 🙂