Login to SSH via public key

24年 9月 26日 Thursday
72 words
1 minutes

How-to

Generate a pair of key

text
ssh-keygen -t rsa

make sure the generated file located on ~/.ssh

text
ssh-copy-id -i ~/.ssh/id_rsa.pub username@ip-addr

make sure you've enable PubkeyAuthentication on the /etc/ssh/sshd_config file

optionally, you can disable PasswordAuthentication if you are pretty sure to not login from other non-authorized device

Bonus

Make the login process more easier by just typing ssh serper.

edit file ~/.ssh/config and append the following section:

text
Host serper
  HostName ip-addr
  User username
  Port 22
  IdentityFile ~/.ssh/id_rsa

RTFM - Read The Friendly Manual

  • scp(1)
  • ssh(1)
  • ssh_config(5)

Title:Login to SSH via public key

Author:ReYuki

Link:https://www.reyuki.site/posts/login-ssh-via-public-key [copy]

Last updated:


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. You are free to share and adapt it, as long as you give appropriate credit, don’t use it for commercial purposes, and distribute your contributions under the same license. Provided under license CC BY-NC-SA 4.0