When the tutorial falls short

I had followed the tutorial step by step for setting up my server with digital ocean. Kept getting stuck on the same step. I had created a new user, given that user root privileges, created the .ssh directory accompanied with an authorized_keys file, changed the permissions of the .ssh folder and authorized_keys file, copied the ssh key from my computer, turned off the password authentication setting within the SSH daemon configuration and restarted the ssh services. Followed the recipe perfectly but still could not connect to my droplet using ssh authentication.

This was my first time setting up a remote server so many of these steps were new to me. I failed at this over dozen times. I even deleted the whole server and started a new just to make sure I wasn’t missing something. I googled around about the permissions I was setting within the folder .ssh as well as the authorized_key file because the error I was receiving on my attempted login stated permission denied. ⇒ ssh user123@111.11.11.111
Permission denied (publickey).
The google search brought me to this digital ocean blog.

After reading this blog and troubleshooting with a friend I had managed to figure it out. What the tutorial had failed to mention is that the authorized_keys file can not be owned by the root user. It has be owned by the user trying to log in (important side note that the root directory should also remain empty). Check out my example.

user123@serversetupName:~/.ssh$ ls -lah

drwx — — — 2 user123 user123 4.0K Dec 14 23:43 .
drwxr-xr-x 3 user123 user123 4.0K Dec 14 23:43 ..
-rw — — — — 1 user123 user123 746 Dec 14 23:43 authorized_keys

When you are in the directory of .ssh for the user123 and then you type the command ls -lah it will list the permissions of that directory. My mistake is that the file authorized_keys was set to root rather than user123.

As with most things in life when you fail. Try, try, try again.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.