0

Let's suppose we have 2 server. The server A and server B The server A and B contain the following linux users 'carlos' and 'peter'

The linux user peter has its .ssh folder with id_rsa, id_rsa.pub and known_host files on server A.

After that, I logged in by putty with user carlos and I scaled to root user by sudo su.

So I wish to copy peter's key(s) from peter@A to peter@B using ssh-copy-id being root. Just in case, I don't know the peter's password on both servers.

Is there any way to copy these keys using ssh-copy-id or another linux command?

1

Just copy the file with scp, rsync, or any other program you are familiar with. There is nothing special with those files.

The ssh-copy-id program is a special tool for a special task, it doesn't fit your requirements.

  • 1
    It might be good to add that private keys probably should not be stored on a server if possible... and that any private keys which are copied should have their permissions set to u+rw or 600 for security purposes... and ssh may refuse to use improperly permissioned keys. – RubberStamp Sep 20 '18 at 17:38
  • @RubberStamp I agree. So let's assume that the keys are at least password protected. – RalfFriedl Sep 20 '18 at 18:38
  • it's not working by copying. The server B asks peter's password, according to example above. Addtionally I gave permissions for files of .ssh folder – user3637971 Sep 20 '18 at 19:50
  • You didn't mention that server B asks peter's password, just that you don't know it. But you did mention being root, so in case it's not obvious you should copy the files as root, and also preserve ownership and permission. On a related note, why not let peter copy the files himself? – RalfFriedl Sep 20 '18 at 20:29
  • Just in case, it's an example about peter and carlos (similar in my real case). About your question, yes, I can let peter copy files himself. It works if copy is made by ssh-copy-id. I also gave files the ownership and permissions being root but it didn't work. My question goes if I could do it being root but I realize that user (in this case peter) should do himself. – user3637971 Sep 21 '18 at 21:36

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.