Set pub key login only for ssh: ================================= First, you will need to create the key pair and place correct files in the ~/.ssh older for your user on both the server and each client. Secondly on Ubuntu delete these secondary config files that can mess up the main config file: sudo rm ssh_config sudo rm ssh_config.d sudo rm -r ssh_config.d Edit the main config file: sudo nano sshd_config Replace the entire file with these contents: # This is the sshd server system-wide configuration file. # The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leave them commented. Uncommented options override the # default value. # Port and ListenAddress options are not used when sshd is socket-activated, # which is now the default in Ubuntu. See sshd_config(5) and # /usr/share/doc/openssh-server/README.Debian.gz for details. #Port 22 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: PermitRootLogin no PubkeyAuthentication yes PasswordAuthentication no PermitEmptyPasswords no AuthenticationMethods publickey KbdInteractiveAuthentication no UsePAM yes X11Forwarding yes PrintMotd no # Allow client to pass locale environment variables AcceptEnv LANG LC_* Save using Ctrl+X Run: sudo systemctl reload ssh You should now have pubkey only auth! -------------------------------------------------------------------------------------------------------------------------------------------- Sources: https://wiki.archlinux.org/title/OpenSSH#Force_public_key_authentication https://branden-g.ddns.net/Notes/Tech_Help/Linux_Repair/Linux_Settings_Changes/Ubuntu_Server/Disable-root-login-for-SSH-on-Ubuntu.txt Date: April 19th 2024