2

Title says it all. I followed this guide to the letter: https://linuxize.com/post/how-to-enable-ssh-on-ubuntu-20-04/ However at the end I was unable to ssh to ubuntu - I get permission denied (publickey). So I went into my sshd_config and modified the following: PermitRootLogin yes PubkeyAuthentication no PasswordAuthentication yes PermitEmptyPasswords no

everything else I left defaulted from a fresh install of ssh server. However, I still cannot log in via ssh, as I get Permission denied (publickey). I find this odd, considering I have explicitly disabled public key authentication. I even tried using the following ssh command: ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no myuser@myserver

However I still get the same result. What on earth am I missing? This seems like it should work. This is in ubuntu 20.04

5
  • 1
    I just realized.....I can ssh via the IP address of my server and it works fine. However, if I attempt using the hostname, this issue happens.
    – Rick D
    Jun 22 '20 at 23:45
  • Ok this keeps getting weirder...when I try to ping it, I get this: a23-202-231-168.deploy.static.akamaitechnologies.com which is NOT my device at all. What is this? Why does it have the same name as my hostname? I am using sambashare as the hostname as I am using it primarily as a samba server - is this a common host?
    – Rick D
    Jun 22 '20 at 23:54
  • You better tell us some more about your local area network. As far as I can determine 23.202.231.168 is a23-202-231-168.deploy.static.akamaitechnologies.com. Jun 23 '20 at 0:32
  • I don't have a clue what that is. However, I did find something interesting. I was attempting this from a terminal in WSL. On a hunch I downloaded putty and tried to ssh in via the hostname from that, and it worked fine! So something is screwy with WSL. I went into the /etc/hosts file and manually added my server/IP (as the IP is static in my network) and now I can ssh using hostname from my WSL terminal. I have no idea what is going on though.
    – Rick D
    Jun 23 '20 at 1:47
  • I can only assume WSL was using some external DNS (Domain Name Service) and got the real answer for something you also seem to use as a local name. Jun 23 '20 at 2:21
1

I had this issue trying to connect from mint 20.04 to an ubuntu 20.04 server. The sshd_config was set up just as you descried on the server.

If you try ssh -v user@hostname you may see it trying a bunch of authentication keys, even though they are not in the config and you're not using the -i at the command line. It keeps trying different keys it finds until the server gets annoyed and closes out the connection.

In this case, try disabling public key authentication on the client (temporarily, one-shot at the command line):

ssh user@servername -o PubkeyAuthentication=no

After doing this, it prompted for a password and successfully logged in. I was also able to use sshpass -pMYPASSWORD ssh user@servername

Example output:

$ sshpass -p<password> ssh -v  <user>@<servername> 
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/<user>/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to <servername> [<servername>] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/<user>/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<user>/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<user>/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<user>/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<user>/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<user>/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<user>/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/<user>/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4
debug1: match: OpenSSH_8.2p1 Ubuntu-4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to <servername>:22 as '<user>'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:r2Ra44NtKxs4WPYKroLMETpd2ebGxUwiKuJdCLqX3fM
debug1: Host '<servername>' is known and matches the ECDSA host key.
debug1: Found key in /home/<user>/.ssh/known_hosts:33
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:Yxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0 /home/<user>/.ssh/<privatekey>
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: RSA SHA256:Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxk <user>@MacBook-Pro.fritz.box
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: RSA SHA256:4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxg root@MacBook-Pro.fritz.box
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: RSA SHA256:qxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxg right@<user>-<computername>-Mint
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: RSA SHA256:zxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxM right@right-<computername>
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: RSA SHA256:vxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc root@unite
Received disconnect from <servername> port 22:2: Too many authentication failures
Disconnected from <servername> port 22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.