ssh over a tunnel in order to configure auto login
        Posted  
        
            by 
                Vihaan Verma
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by Vihaan Verma
        
        
        
        Published on 2012-10-06T09:35:19Z
        Indexed on 
            2012/10/06
            9:39 UTC
        
        
        Read the original article
        Hit count: 469
        
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 ?
© Server Fault or respective owner