Google

SSH Key Problem Troubleshooting

I’ve wasted enough time with these seemingly simple tasks to warrant a quick post. The problem is that you’ve created keys, put the relevant files all over the place, but nothing seems to be working.
  • Permissions
    authorized_keys and authorized_keys2600
    .ssh700
    Home Directory711
    Keys (id_dsa,id_rsa)600
    Public Keys (id_dsa.pub,id_rsa.pub)644
    The permissions shown are the maximum, you could put less…
  • Account locked.
    You created an account, created a key, got everything in the right location but you cannot ssh in using the key.
    If you used useradd and didn’t set a password, then the acount is locked. Edit /etc/shadow and change
    user:!!: to user:*:
  • SSH Permit
    You forgot that you have an AllowUsers in /etc/ssh/sshd_config
    Add the user to AllowUsers
    AllowUsers previous users this user
    Note: this allows the users: previous; users; this; and user access to the machine
    You forgot that you have a DenyUsers in /etc/ssh/sshd_config
    Remove the user from DenyUsers
    Note: if this is your issue, you’ve been smoking too much weed
  • Still doesn’t work, you get key-error or protocol mismatch.
    • You are using an rsa1 key on a host that supports only ssh2 (rsa and dsa keys).
      Note to self: Get with it buddy, ssh1, “what’s with you man?”
    • You are using a dsa or rsa key on a host that supports only ssh1 (rsa1).

8 Responses to “SSH Key Problem Troubleshooting”

  1. » Howto backup a directory using rsync and ssh - Sysadmin Ramblings » Blog Archive Says:

    [...] « SSH Key Problem Troubleshooting [...]

  2. Paul Hepworth Says:

    Thanks for the tips. It seemed that my problem/solution was not on your list. I had an issue where my keys were compromized. You can check it out here:

    http://peppyheppy.com/2009/1/14/fail-compromised-ssh-public-key-on-ubuntu

  3. k3ri Says:

    Also, when trying to do root logins (only on SECURED systems):

    1) make sure that you set: PermitRootLogin yes
    2) make sure that you set the root directory properly in /etc/passwd (IE: /root/.ssh/authorized_keys doesn’t work if you have root homedir set to /)
    3) Profit.

  4. uphill Says:

    collect underpants?

  5. ali Says:

    Very useful- also remember if setting up the key for a user other than root, that the authorized_keys file is owned by the correct user/group.

    Cheers

  6. Matt Evans Says:

    Also, if you used cut and paste method to create/enter key into authorized_keys, make sure the key is one continuous line and not broken by linefeeds or CRs.

  7. Arjun Says:

    Thanks for the info, it helped me solve a problem with my ssh setup – which I was doing for the first time …

  8. Carlos Says:

    Awesome…my problem was as simple as a permission problem. Thanks for the post.

Leave a Reply