Is this possible? If so how?

The server that I want to copy a ssh key to, only allows authentication with a keyfile rather than username and password.

I am able to login to the server with ssh -i ...


I just checked and ssh-copy-id supports the -i [identity_file] option just like you would use it for ssh.

If that doesn't work for you, you can see if your version can do this option:

-o ssh -o IdentityFile ~/backups/.ssh/id_dsa

Next you could try updating your version of ssh-copy-id. Lastly, you can simply copy/paste the public key after you ssh in.


If you have your ssh-agent running and the old key with which you can already log in is loaded it should work like this:

ssh-copy-id -i new-key user@host


ssh-copy-id -i new-key host-alias-from-config

I had to add -f but I am not sure if that was an error on my part.

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.