1

I freshly installed Ubuntu 20.04.04 on a laptop and performed all necessary steps to enable SSH on it:

sudo apt-get update
sudo apt-get install openssh-server

I am fully aware and verified the IP, username and password on this Ubuntu laptop. I have also disabled firewall on this machine.

But when I attempt to ssh to this machine I get following error:

[myusername@mycomputername ~]$ ssh ubuntuname@ubuntuip
ubuntuname@ubuntuip's password:
Permission denied, please try again.
ubuntuname@ubuntuip's password:

After looking at multiple forums and websites it was identified to make sure following settings are enabled on /etc/ssh/sshd_config on my ubuntu machine.

PermitRootLogin yes
PasswordAuthentication yes

I have also enabled permissions on:

chmod 0700 /home/ubuntuname
chmod 0700 /home/ubuntuname/.ssh
chmod 0600 /home/ubuntuname/.ssh/authorized_keys (created this file)

Based from Nasir's comment below also added AllowUsers myusername@mycomputername on my ubuntuname machine's sshd_config file.

And finally;

sudo systemctl restart sshd

I have confirmed that I can login directly (i.e. without ssh) to the ubuntuip server as ubuntuname. The UID for ubuntuname is 1000.

ubuntuname@ubuntuname:~$ journalctl -g sshd
Mar 22 17:38:12 ubuntuname systemd[1]: ssh.service: Found left-over process 8916 (sshd) in control group while starting unit. Ignoring.
Mar 22 17:38:25 ubuntuname sshd[14878]: pam_unix(sshd:auth): check pass; user unknown.
Mar 22 17:38:25 ubuntuname sshd[14878]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=<remote_host_IP>
Mar 24 11:03:50 ubuntuname sshd[17659]: pam_unix(sshd:auth): check pass; user unknown.
Mar 24 11:03:50 ubuntuname sshd[17659]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=<remote_host_IP>
Mar 24 11:47:09 ubuntuname sudo[17750]: ubuntuname : TTY=pts/0 ; PWD=/home/ubuntuname ; USER=root ;  COMMAND=/usr/bin/nano /etc/ssh/sshd_config
Mar 24 11:47:50 ubuntuname sudo[17754]: ubuntuname : TTY=pts/0 ; PWD=/home/ubuntuname ; USER=root ;  COMMAND=/usr/bin/systemctl restart sshd
Mar 24 11:48:16 ubuntuname sshd[17760]: pam_unix(sshd:auth): check pass; user unknown.
Mar 24 11:48:16 ubuntuname sshd[17760]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=<remote_host_IP>

Nothing seems to work so far to login to my ubuntu machine. What am I missing here?

17
  • Is the user allowed in the /etc/ssh/sshd_config file? Mar 21, 2022 at 19:24
  • 2
    Any useful messages in /var/log/auth.log?
    – doneal24
    Mar 21, 2022 at 19:34
  • 1
    @Nasir how do you allow user in the sshd_config file?
    – eecs
    Mar 21, 2022 at 19:41
  • Add the line AllowUsers username to the file and restart the service. Did you research this via Google beforehand? This is one of the first things that you'll find. Mar 21, 2022 at 21:49
  • After adding AllowUsers mycomputer@username on my ubuntuname machine's sshd_config file and restarting the service did not help in this case
    – eecs
    Mar 22, 2022 at 22:43

1 Answer 1

-1

you may try this command:

sudo passwd username

In your case the you should execute below by order:

sudo passwd ubuntuname

set password for username, then:

ssh ubuntuname@ubuntuip
1
  • 1
    Note that they say they have verified that the username and password are correct and that they can log in directly on the machine.
    – Kusalananda
    Jun 16, 2022 at 14:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .