Harden SSH Access?

I am having difficulty with step 2 - https://www.linode.com/docs/security/se … our-server">https://www.linode.com/docs/security/securing-your-server.

$ scp ~/.ssh/linode_id_rsa.pub usr@xx.xx.xxx.xxx:/.ssh/authorized_keys
$ usr@xx.xx.xxx.xxx's password: 
$ scp: /.ssh/authorized_keys: No such file or directory

How can I resolve this? I am unable to cd into the directory. Should I exit and attempt this as root?

4 Replies

````
$ scp ~/.ssh/linodeidrsa.pub usr@xx.xx.xxx.xxx:/.ssh/authorized_keys

Looks like you left out the ~ on the remote side, I think it should be

$ scp ~/.ssh/linodeidrsa.pub usr@xx.xx.xxx.xxx:~/.ssh/authorized_keys
````

@Stever:

$ scp ~/.ssh/linode_id_rsa.pub usr@xx.xx.xxx.xxx:/.ssh/authorized_keys

Looks like you left out the ~ on the remote side, I think it should be

$ scp ~/.ssh/linode_id_rsa.pub usr@xx.xx.xxx.xxx:~/.ssh/authorized_keys

Bah! My mistake. This worked. However, it tells me that Permission is Denied after entering my password. Would this be relevant to CHMOD?

Yes, check your access (and owner) bits.

And also, to copy the public key over .ssh/authorized_keys isn't the best method, unless you only ever want to allow access from just one single source. Normally you would _append_ to authorized_keys, like so:

cat ~/.ssh/idrsa.pub | ssh usr@xx.xx.xxx.xxx "cat >> .ssh/authorizedkeys"

(I wrote idrsa.pub there, I'm not sure why you have a file named linodeid_rsa.pub unless you really changed the default name of your local rsa key file(s))

If it exists on your home system, ssh-copy-id automates the process of copying a key and makes it much easier.

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