Shreyas Jani

I'm a web designer & software engineer based out of Mumbai.

I write about technology & love documenting the world around me through photography.

Disable SSH password based authentication on Ubuntu

31 May 2020

SSH'ing into my old laptop and working has become an integral part of my workflow. All my code is hosted on this remote machine that I SSH into and I've been using VS Code's Remote - SSH extension to access the code and work on it.

Given how my Macbook running Ubuntu has space restrictions (it's a 2017 Macbook air with 128gb SSD), hosting code of multiple projects on a more spacious machine with decent computing power is a must have for me.

While it is a good thing I've got passwordless SSH authentication in place, I also felt the need to disable password based authentication for additional security.

Disabling SSH password based authentication

After ensuring I can securely SSH into my remote machine, I've followed these steps to disable password based authentication.

→ ssh remote_user@remote_server_ip

I opened the SSH configuration file at → sudo vim /etc/ssh/sshd_config.

Unmodified, the file should have these entries

#To disable tunneled clear text passwords, change to no here!

#PasswordAuthentication yes

#PermitEmptyPasswords no

I've Modified the #PasswordAuthentication yes to PasswordAuthentication no. And I made sure I removed the # so that the line is uncommented.

The entries now look like this:

#To disable tunneled clear text passwords, change to no here!

PasswordAuthentication no

#PermitEmptyPasswords no

Once done, I restarted the SSH service by running → sudo systemctl restart ssh