I have made a new user and key but when I access remotely its asking for passphrase but I didn't set one. I have also redone it to triple check. Below are command I ran and error. Can anyone see any obvious error with my commands to create the key?:

useradd -m -d /home/webuser -s /bin/bash webuser
su webuser
ssh-keygen -t rsa
cat id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
rm id_rsa.pub

ssh webuser@ip_of_target_server
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /root/.ssh/id_rsa ((nil)),
debug2: key: /root/.ssh/id_dsa ((nil)),
debug2: key: /root/.ssh/id_ecdsa ((nil)),
debug2: key: /root/.ssh/id_ed25519 ((nil)),
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/root/.ssh/id_rsa':
debug2: no passphrase given, try next key
debug1: Trying private key: /root/.ssh/id_dsa
debug3: no such identity: /root/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /root/.ssh/id_ecdsa
debug3: no such identity: /root/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /root/.ssh/id_ed25519
debug3: no such identity: /root/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

2 Answers 2


You're mixing up multiple things.

You have not set a password for the user you created so it effectively can't login using a password so SSH won't ask for it.

However, when you created your SSH key, you password protected the key. When it attempts to connect to the server, it needs to read that key to verify your identity and thus, asks for the key password.

Also, I'm missing a few steps between when you add the key to the authorized keys and when you try to connect but it looks (from how things are done, no actual indication in logs) like the key you've added to the authorized keys is not the one you have on the machine that's attempting to connect.

  • The Enter passphrase for key '/root/.ssh/id_rsa': prompt indicates that the key has a password/phrase, and that's the password that is being asked for here.
    – DerfK
    Apr 20, 2017 at 21:51
  • Do I need to set a password? I don't really want a password for this user. Which command did I password protect the key? Thanks Apr 20, 2017 at 21:59
  • When you ssh-keygen it will prompt you for a password, you may hit enter without typing anything to not set one. Apr 20, 2017 at 22:00
  • However as I mentioned and as @olivierg mentioned in his quite complete answer, I think it's more of a case of wrong private key being used. What did you do with the id_rsa after you deleted id_rsa.pub? Apr 20, 2017 at 22:03
  • I put id_rsa onto the server I'm connecting from. /root/.ssh/id_rsa Apr 20, 2017 at 22:07

you need to :

  • ensure that your destination .ssh folder has the right permissions (usually 700) and not something too open (e.g not 775 or other)
  • ensure that your destination authorized_keys has the right perms also (usually 644)
  • ensure that your source private key has the right perms (600, max)
  • ensure that your source and destinations home directories have the right permissions (not too open, once again)
  • ensure that the key in authorized_keys doesn't have spaces or newlines in it (it shouldn't be the case with your cat)
  • ensure that you are using the right private key while performing your ssh/scp/sftp (it should use id_rsa by default)

also, what is the ssh command you are using ? from 'which user' to 'which user' ? if you try to ssh to the root account of another machine, you also need to ensure that its sshd_config file has PermitRootLogin yes or WithoutPassword no

and reminder : the public key you generate need to be deployed in the target user's authorized_key file. so when you do a

ssh -i /root/.ssh/id_rsa root@remote_machine

it works without any password (if you didn't set a password when using ssh-keygen -t rsa, it prompted you, and you have to hit enter twice, don't enter any value)

hope that helps

also, it looks like you created a user called webuser, but you are trying to perform your ssh from the root user.. it won't work. you have to create a keypair in a specific user, and deploy the contents of the public key to the other user/machine you want to target.

  • We know from the debug connection attempt that the local .ssh has the right permissions since SSH would otherwise refuse to read it so you can strike that one :) Apr 20, 2017 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.