Skip to content

Latest commit

 

History

History
48 lines (47 loc) · 1.1 KB

copy_key_to_server.md

File metadata and controls

48 lines (47 loc) · 1.1 KB

Copy the public key of the client to ~/.ssh/authorized_keys of the host

  1. At host
    • First, edit /etc/ssh/sshd_config to turn on password login.
      sudo vim /etc/ssh/sshd_config
      
    • Find and comment these two lines
      PasswordAuthentication no
      PubkeyAuthentication yes
      
    • Restart ssh.
      sudo systemctl restart ssh
      
  2. At client
    • Generate your private/public key pair.
      ssh-keygen
      
    • Copy client public key from client to host.
      ssh-copy-id <user>@<host IP>
      
    • Check if it works.
      ssh <user>@<host IP>
      
    • Remove passphrase [optional]
      ssh-keygen -p
      
  3. At host
    • Edit /etc/ssh/sshd_config again.
      sudo vim /etc/ssh/sshd_config
      
    • Find and uncomment these two lines
      PasswordAuthentication no
      PubkeyAuthentication yes
      
    • Restart ssh.
      sudo systemctl restart ssh