Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I m trying to copy the id_rsa.pub key to the server. The server in my case also has a virutal machine called dev which runs on the host machine. I copied the id_rsa.pub key to the host for auto log in using this command.

ssh-copy-id -i ~/.ssh/id_rsa.pub vickey@host

which worked fine and I can auto log in to host. I also wanted to auto log in to the dev machine. I know I can just copy the contents of authorized_keys from the host machine to the dev machine but I m looking for a command line of doing things. Creating a tunnel seemed like the solution

ssh vickey@host -L 2000:dev:22 -N

now when I tried

ssh-copy-id -i ~/.ssh/id_rsa.pub vickey@localhost -P 2000

the password that worked here was of my local machine , I expected it to ask me password of my dev machine. The above command adds the pub key to the local machine and not to the dev machine.

However this commands asks me for the dev password and copies the files.

scp -P 2000 vickey@localhost:/home/vickey/trash/vim .
vickey@localhost's password: 
vim                                                  100%  111     0.1KB/s   00:00   

How do I do the same with ssh-copy-id ?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The problem is that ssh-copy-id has no switch -P. Also, please read this post to understand why you will not be able to log in with ssh -p 2000 vickey@host.

So you either need to create new identity at host and then copy it's public key to dev, or you copy your existing private key to host and then it's public key to dev. The first option is preferable.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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