0

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 ?

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .