TrumanWong

ssh-copy-id

Install the local ssh public key file to the account corresponding to the remote host

Supplementary instructions

ssh-copy-id command can copy the public key of the local host to the authorized_keys file of the remote host. The ssh-copy-id command will also copy the user home directory (home) and ~/.ssh of the remote host. , and ~/.ssh/authorized_keys set appropriate permissions.

ssh-copy-id When using ssh to log in to a remote server, the user identity is generally verified through password, so the password verification method should be enabled in the configuration of sshd: Set PasswordAuthentication in /etc/ssh/sshd_config to yes, and then restart sshd

grammar

ssh-copy-id [-i [identity_file]] [user@]machine

Options

-i: Specify the public key file

Example

  1. Install the local ssh public key file to the account corresponding to the remote host:
ssh-copy-id user@server
ssh-copy-id -i ~/.ssh/id_rsa.pub user@server