So I have created to vm's with the ubuntu 16.04 version. I'm trying to copy my public key into the authorized_keys file, how I have done this is with the command cp id_rsa.pub home/vagrant/.ssh/ I done the command from the home/deploy/.ssh/ directory but I get the following error: cp: cannot create regular file 'home/vagrant/.ssh/': No such file or directory. Can anyone tell me why I'm getting this error.

Thank you for the help in advance.


The command fails because you need a forward slash at the start of the path, like this:

cp id_rsa.pub /home/vagrant/.ssh/

In order to actually use the key, you can add the key to authorized_keys with this command:

cat id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
  • thanks for the help that seemed to work now I'm getting permission denied so I done the command as the root user and it seemed to copy fine just need the authorized_keys file if it actually copied into it. Jun 1 '21 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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