How do i copy my public ssh key from one machine to another?



  • Always ensure the you are aware of the security implications of sharing ssh keys between machines. In some case you need to do it as part of an installation procedure.

    This copies the pub key from one user to the same user on another machine. The first time you enter the password of the remote user, subsequent use of ssh'ing into the remote machine as that user is done through ssh key authentication.

    $ ssh-copy-id [email protected]
    /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/trainer/.ssh/id_rsa.pub"
    The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
    ECDSA key fingerprint is SHA256:xxxxxxxxxx.
    Are you sure you want to continue connecting (yes/no)? yes
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    [email protected]'s password: 
    
    Number of key(s) added: 1
    
    Now try logging into the machine, with:   "ssh '[email protected]'"
    and check to make sure that only the key(s) you wanted were added.
    

Log in to reply
 

© Lightnetics 2024