Here are steps what i did for ssh key connection:

  1. generated ssh key, the i checked /User/admin/.ssh/ here i have idrsa, idrsa.pub and known_hosts.
  2. I copied idrsa.pub 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.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
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.

Jarland

Submit an Answer