Results 1 to 8 of 8

Thread: SSH Key User Authentication fails

  1. #1

    Default SSH Key User Authentication fails

    Hi together!


    • Created a new user via yast2
    • Created a key pair
    • Tested key pair with another user ==> Works
    • copy key to new user
    • chown <new user>:users authorized_keys
    • Checked all access configurations: Fine
    • But server doesn't accept the key


    Something in the new user configuration prevents the fit of the keys. Does anybody know what that could be? Nothing in Google found.

    Thanks a lot!

    Christof

  2. #2
    Join Date
    May 2012
    Location
    Finland
    Posts
    2,001

    Default Re: SSH Key User Authentication fails

    Most likely it's a problem with your authorized_keys permissions and as such you should try using ssh-copy-id from the source user/machine to the target user/machine as it will set the permissions accordingly and alert you to any issues along the way.

    You can run it from your client, logged in as the user whose ssh public key you wish to copy to the target server: ssh-copy-id user@targethost
    .: miuku #suse @ irc.freenode.net
    :: miuku@opensuse.org

    .: h​ttps://download.opensuse.org/repositories/home:/Miuku/

  3. #3
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,025
    Blog Entries
    3

    Default Re: SSH Key User Authentication fails

    Make sure that "authorized_keys" is not group writable nor writable by others.

    Make sure that your home directory is not group-writable nor writable by others.

    Make sure that your ".ssh" directory is not group-writable nor writable by others.
    openSUSE Leap 15.1; KDE Plasma 5;

  4. #4
    Join Date
    Mar 2011
    Location
    Sauerland
    Posts
    3,740

    Default AW: SSH Key User Authentication fails

    Did you change the authorized_keys on the server to your new Username?
    ssh-rsa key Username@PC-Name

    But ssh-copy-id is the tool to copy the key to the Server......

  5. #5

    Default Re: SSH Key User Authentication fails

    Hi folks!
    Thanks a lot for your suggestions, but doesn't solve the problem. I repeat: "Tried the keys with another user and it worked". That excludes any problems with permissions or ownerships. If I got the key running for user1 why not for user2? The key wasn't generated on the server, so the adaption of the permissions / ownerships had to be done for user1 and user2 in the same way. The hint with the home directory was an idea, but as all users have the same permissions here, this isn't a clue either. (Anyway I tried - but to no avail). Anyhow I assume from your answers that there isn't any user configuration known, which could prevent the correct authorization?

    Thanks and ATB!

    Christof

  6. #6
    Join Date
    Mar 2011
    Location
    Sauerland
    Posts
    3,740

    Default AW: SSH Key User Authentication fails

    If I got the key running for user1 why not for user2?
    Do you change the name to user2 on the server in the authorized_keys?
    Also the user2 Name of the Hostname?
    Code:
    hostname -f

  7. #7

    Default Re: SSH Key User Authentication fails

    Quote Originally Posted by nrickert View Post
    Make sure that "authorized_keys" is not group writable nor writable by others.

    Make sure that your home directory is not group-writable nor writable by others.

    Make sure that your ".ssh" directory is not group-writable nor writable by others.
    The second sentence was what was causing me trouble. In my case, user1 was my main user account and user2 was a "transfer" account where I could transfer files in and out of it through my phone. (I didn't want to give my phone access to my home directory for obvious security reasons.)

    /home/user2 was: drwxrwx--- 8 user2 foo 4096 Oct 27 07:11 user2

    where group foo was specifically set up for making transfers. User1 was a member of that group and had writeable access. Once I changed the directory to drwxr-x--- everything worked fine.

    Anyway, I didn't know this about SSH. I knew the other stuff above, but this had me stumped for a while.

    Another good link for info is: https://serverfault.com/questions/39...om-local-ubunt

  8. #8
    Join Date
    Oct 2014
    Location
    Rotterdam
    Posts
    140

    Default Re: SSH Key User Authentication fails

    One other suggestion on how to debug this is to turn on the ssh debug output (ssh -vvv) and compare/diff the output for the two users.
    If you do not see what is wrong, post the output for the failing user here...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •