In my VPS, run ssh-add -l
and it returns: The agent has no identities.
but I have run cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys'
previously
I then run ssh-add ~/.ssh/authorized_keys
it returns @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/deployer/.ssh/authorized_keys' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
and ssh [email protected]
still get report Permission denied (publickey).
The currently most up voted answer is plainly wrong as it fails to understand the question. OP is asking how to authorize a key on a remote server, not how to add a key to your local ssh-agent.
To add a key to a remote server use the ssh-copy-id
command from your local PC:
ssh-copy-id -i path/to/key.pub username@remoteHost
This adds the public key located at path/to/key.pub
with the correct permission to the server at remoteHost
using username
as login name. Note that this also seems to require the private key next to the public key (the path/to/key
file in this example).
To add your ssh-key to your ssh-agent you have to add it with:
ssh-add
After that ensure your key is added:
ssh-add -l
To fix your permission problem try:
chmod 0600 ~/.ssh/authorized_keys
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With