Cannot login with pubkey

September 18, 2018 311 views
DigitalOcean Ubuntu 18.04

Here are steps what i did for ssh key connection:

  1. generated ssh key, the i checked /User/admin/.ssh/ here i have idrsa, and known_hosts.
  2. I copied to ~/.ssh/authorizedkeys - (I triple checked taht they are the same) (btw i used ssh root@ip)
  3. then i tried to connect to ssh root@ip again. but it doesnt accept the key(password auth method worked after pubkey fail). Ubuntu 18.04.
1 Answer

Hey friend!

That is interesting. The good news is that you can limit your scope of thought on this to a fairly small set of items. There's only so much that can go wrong here. Try this:

ssh -vvv root@IP

See if you get anything in the output that tries to explain the failures. Maybe it couldn't load id_rsa, for example, and advises on permission changes. Seems unlikely to have permission issues though if you used ssh-keygen. So glance at that but if you see nothing, let's move on.

Double check that the items in /root/.ssh/authorized_keys are valid. One key per line, no line breaks, no weird spaces. Your key should look something like mine:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLmqjzH1lJ+uTlL2yGjyOcFKdxYFWYLSUdqN5LMRA1YiXHJvTkOo4Ky8w8NmNqJoKwLhxESLNpdUteZbacCRf3I9j57td8IaySk3LFpNK1waDwPcwFlvOv6NtKdwFsgQ0CUqJ6Ya9AUVfTlyePBhH9lKy7gnsloAtHOfGlHdCt5X5f2iB0WU/PPZZskfj79z84dlUPrdfdq8DZmOQDnTEF6XnqaYIqrYXKnPOTovCnOGrc1xJjV+UQ7dZhc/5UCECDK8DEUKZ21aK5htCwhqQFLVV4M6SB7/mDiWXvNx79hKuHDHsHCv6L4YuqHkHAGNtmHq2UxntJ9K6i0DxoMq/1 jarlanddonnell@Jarlands-iMac.local

Also unlikely that key login is disabled on the droplet, so I'm kind of thinking you may find something there in authorized_keys.


Have another answer? Share your knowledge.