ssh into Mint requires password even with keyfile

Questions about Wi-Fi and other network devices, file sharing, firewalls, connection sharing etc
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Nomin
Level 3
Level 3
Posts: 160
Joined: Sat Dec 21, 2013 7:21 pm

ssh into Mint requires password even with keyfile

Post by Nomin »

I'm trying to setup an rsync job from a remote machine to my Linux Mint desktop via ssh, and without the need to enter a password for a headless, unattended cronjob. But my Mint machine always asks for pw.

Here steps I followed:

On remote machine (Raspberry Pi running Raspbian) I run this command to create the required key:

Code: Select all

ssh-keygen -t rsa
Copy it from remote machine to my Mint desktop

Code: Select all

ssh-copy-id -i ~/.ssh/id_rsa.pub USER@MINT-IP
Test that the ssh connection doesn't ask for pw:

Code: Select all

ssh 'USER@MINT-IP'
I get a password prompt :( I also get the prompt if I try rsync. I have verified that the key in file id_rsa.pub created in the first step above is indeed on my Mint machine's ~/.ssh/authorized_keys file.

When I do it from the other machine, i.e. follow the same steps from my Linux Mint machine, I can log into my RPi without password prompt! This to me suggests there is some setting in Mint which is disallowing login without a password.

I have the following fields in /etc/ssh/sshd_config , which should be the correct ones:

Code: Select all

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile     %h/.ssh/authorized_keys
Owner of the file authorized_keys is USER mentioned above, and permissions are 600.

Running out of ideas to troubleshoot. Any takers?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
UltramaticOrange

Re: ssh into Mint requires password even with keyfile

Post by UltramaticOrange »

This is the behavior when permissions are set incorrectly on your .ssh directory or the containing files. Easy solution is to chmod ~/.ssh to 700 and all the files within to 600. I say "easy" because not every file needs to be 600, but setting things that way won't break anything.
Nomin
Level 3
Level 3
Posts: 160
Joined: Sat Dec 21, 2013 7:21 pm

Re: ssh into Mint requires password even with keyfile

Post by Nomin »

UltramaticOrange wrote:This is the behavior when permissions are set incorrectly on your .ssh directory or the containing files. Easy solution is to chmod ~/.ssh to 700 and all the files within to 600. I say "easy" because not every file needs to be 600, but setting things that way won't break anything.
Same result, below what the permissions are on the destination machine.

Code: Select all

drwx------  2 USER USER      4096 May 15 12:43 .ssh

-rw------- 1 USER USER  396 May 14 21:36 authorized_keys
-rw------- 1 USER USER  396 May 14 21:20 authorized_keys2
-rw------- 1 USER USER 1679 May 14 21:36 id_rsa
-rw------- 1 USER USER  401 May 14 21:36 id_rsa.pub
-rw------- 1 USER USER  888 May 14 20:28 known_hosts
Could it be the owner of the files what is the culprit? The user and owner of the .ssh folder and files in it on the Raspbian machine is "pi", and the user on the Mint desktop is "nomin" ("USER" above). Could the different owner names be the issue? I am logging into as "nomin" from the Raspbian machine to my Mint box, which should be correct.
UltramaticOrange

Re: ssh into Mint requires password even with keyfile

Post by UltramaticOrange »

The user shouldn't be an issue; pi@raspi should be able to login as USER@mint when the keys are correct. Take a look at the authorized_keys file on your mint desktop and confirm that the public key from the pi got copied over correctly. The last bit on the line should be 'pi@raspi'. If that looks okay, check that the key looks the same as the id_rsa.pub on the pi. If that seems to be okay, on the mint desktop, change 'pi@praspi' to 'pi@*' in the authorized_keys file (this is what I often do to avoid issues with changing IPs from dhcp).
UltramaticOrange

Re: ssh into Mint requires password even with keyfile

Post by UltramaticOrange »

Forgot to mention: The authorized_keys2 file is odd. It wont' cause any issues but I'd take a look at it, confirm that there isn't anything in there I care about and then delete it.
Nomin
Level 3
Level 3
Posts: 160
Joined: Sat Dec 21, 2013 7:21 pm

Re: ssh into Mint requires password even with keyfile

Post by Nomin »

changed pi@raspberrypi to pi@* on the destination machine (Mint), and deleted the authorized_keys2 file (it was instructed as a possible workaround in one doc I found online), and now it finally works! I didn't bother to look if the authorized_keys2 file had a different public key, so it could be that, or the pi@* -change which fixed it - but as long as it works I'm ok!

Thank you very much for your help and patience :)
Locked

Return to “Networking”