Score:4

SSH Permission Denied

ci flag

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.

user10489 avatar
in flag
usually permission denied with ssh means your user authentication failed. ssh key? password? trying to ssh as root (normally disabled)?
ag flag
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.
Score: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
FilterFeeder avatar
ci flag
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 avatar
ci flag
$ 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 avatar
ci flag
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?
sancho.s ReinstateMonicaCellio avatar
pl flag
@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.
Archemar avatar
cn flag
`.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))
sancho.s ReinstateMonicaCellio avatar
@FilterFeeder - Any feedback?
FilterFeeder avatar
ci flag
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.
sancho.s ReinstateMonicaCellio avatar
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.
Score:1
in flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.