Guides & Tutorials: Securing Your Server

I have a new Centos 7 Linode and have been following this guide to secure:

https://www.linode.com/docs/security/se … our-server">https://www.linode.com/docs/security/securing-your-server

Adding a New User

Works fine

Using SSH Key Pair Authentication

In a terminal on my Mac, changing example_user, IP address as appropriate:

ssh-keygen

scp ~/.ssh/idrsa.pub exampleuser@123.456.78.90:

In a terminal to my server

mkdir .ssh

mv idrsa.pub .ssh/authorizedkeys

chown -R exampleuser:exampleuser .ssh

chmod 700 .ssh

chmod 600 .ssh/authorized_keys

The guide says:

"The SSH keys have been generated, and the public key has been installed on your Linode. You’re ready to use SSH key pair authentication! To try it, log out of your terminal session and then log back in. The new session will be authenticated with the SSH keys and you won’t have to enter your account password."

I cannot get past this stage. Any new session is not authenticated with the SSH keys. Any guidance what I am doing wrong?

Thanks

2 Replies

I'm fairly sure the authorized_keys should be 644 (publicly readable, user only write)

otherwise, the ssh process cannot load your public key for authentication

Edit: I take that back… man pages recommend 600 (so the problem is elsewhere)

try checking the output of

$ ssh -vv example_user@server_ip

Cheers. I found the issue to be naming the file something other than id_rsa which need to do if have multiple SSH keys. Need to have a config file in the ~/.ssh folder to specify which key to use for which server.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct