4

I have a bunch of computers I'm trying to connect to each other with some random router I found lying around. I have all the machines connected to the router and have given them fixed IPs. I have used ssh before and I thought it would be super easy just remote-control the other machines with ssh, but for some reason I get this "permission denied, please try again"-error.

I've tried making firewall adjustments, various conformations of the /.ssh/sshhd_config, but nothing works. I'm at least sure that the machines can "see" each other, since when I enter the IP I'm asked for the password of a username@machinename of the computer I know I'm connecting to.

I'm worried that I may have some configurations to do with my router, or that I'm somehow giving bad static IPs, but in those regards I don't have a first clue about what to do. Do you guys have any other suggestions as to what might be wrong?

Oh yeah, I'm using Ubuntu 20.04.

FilterFeeder
  • 51
  • 1
  • 1
  • 5
  • 2
    usually permission denied with ssh means your user authentication failed. ssh key? password? trying to ssh as root (normally disabled)? – user10489 Nov 29 '21 at 05:24
  • Adding a lot of `-v` to your ssh command give information about what happens. The sshd log on the server might even say explicitly what is wrong. – Thorbjørn Ravn Andersen Nov 29 '21 at 13:58

2 Answers2

6

It is most likely a problem with permissions. For security reasons, this is the required/recommended list of permissions for the files that most typically give problems to users:

  • directory ~/.ssh: 0700 (drwx------)
  • file ~/.ssh/authorized_keys: 0600 (-rw-------)
  • file ~/.ssh/config: 0600 (-rw-------)
  • file ~/.ssh/id_rsa (or other private keys): 0600 (-rw-------)

For more details, see 1. Please check that and post feedback.

If that doesn't work, you might check file /etc/ssh/sshd_config. If you have PasswordAuthentication no, change it to yes. Depending on other settings, simply commenting it might work as well. Then restart the service with sudo service sshd restart. You mention you introduced changes to this file, I don't know which were these.

If that doesn't work, I suggest you post the output of the commands below. Further try to interpret that, you may find the answer yourself. And check the links below, they may also help.

$ cat /etc/ssh/sshd_config
$ ssh -v ...
$ ls -al ~/.ssh
$ ls -ald ~/.ssh

Related:

  1. SSH error: Permission denied, please try again
  2. https://www.digitalocean.com/community/questions/permission-denied-please-try-again-error-in-ssh
  3. https://serverfault.com/questions/288223/loggin-in-ssh-server-permission-denied-please-try-again
  • Thank you for your reply. I notes that node1 doesn't have the file ~/.shh/id_rsa, and none of the nodes has the files ~/.ssh/config. Was this a type-o on your part or does it indicate some permission issue? I tried now to change the permissions as you said, to the extent that the files exists, but without solving the problem. Posting to above mentioned outputs in a bit. – FilterFeeder Nov 29 '21 at 09:51
  • $ sudo ls -al ~/.ssh total 28 drwx------ 2 carl-johan carl-johan 4096 nov 26 12:59 . drwxr-xr-x 27 carl-johan carl-johan 4096 nov 25 11:20 .. -rw------- 1 carl-johan carl-johan 2602 nov 26 12:56 authorized_keys -rw-r--r-- 1 carl-johan carl-johan 570 nov 26 12:56 authorized_keys.pub -rw------- 1 carl-johan carl-johan 1381 nov 24 16:53 id_dsa -rw-r--r-- 1 carl-johan carl-johan 606 nov 24 16:53 id_dsa.pub -rw-r--r-- 1 carl-johan carl-johan 1110 nov 26 13:00 known_hosts – FilterFeeder Nov 29 '21 at 09:59
  • Sorry I have to ask a very ignorant question, how do I post the outputs without making them look like crap and also make them fit the limited character count? – FilterFeeder Nov 29 '21 at 10:01
  • 2
    @FilterFeeder - You should post any additional info in the question itself, and format it as code. Otherwise, people have to read many disperse pieces of information... that may make more difficult for people to help you. – sancho.s ReinstateMonicaCellio Nov 29 '21 at 11:39
  • `.ssh/config` and `.ssh/id_rsa` are in local node (the one you connect **from**), `.ssh/authorized_keys` is on distant node (where you connect **to** (and can be 644)) – Archemar Nov 29 '21 at 14:56
  • @FilterFeeder - Any feedback? – sancho.s ReinstateMonicaCellio Dec 01 '21 at 17:53
  • Yes, sorry I though I posted this, but I solved it simply be re-installing ssh client and server and it worked. I think I also didn't realize that if the usernames are different between the server and client, I have to specify it in the ssh command. – FilterFeeder Dec 02 '21 at 12:38
  • I guess you should post this in the question, or rther as answer and mark it solved. It is a good way of giving feedback to a community that helped you somehow. – sancho.s ReinstateMonicaCellio Dec 02 '21 at 13:02
1

In my case, a fresh install of Ubuntu 22.04.1, I was attempting to connect using password authentication and the line PasswordAuthentication yes was commented out in /etc/ssh/ssh_congig.

I needed to uncomment the line and restart SSHL service sshd resart

Additionally, I first connected with powershell from a windows machine it prompted me to accept the finger print, which I did. However, once I connected using ssh -v hostname@servername powershell dumped errors that REMOTE HOST IDENTIFICATION HAS CHANGED!.

The solution was to delete the host from %userprofile%/.ssh/known_hosts and re-accept the thumbprint.