how to SSH Login Without Password

╰半橙微兮° 2022-06-14 07:20 205阅读 0赞
  1. cd ~/.ssh
  2. ssh-keygen -t dsa

press the enter key at every prompt

  1. Generating public/private dsa key pair.
  2. Enter file in which to save the key (/home/user/.ssh/id_dsa):
  3. Enter passphrase (empty for no passphrase):
  4. Enter same passphrase again:
  5. Your identification has been saved in /home/user/.ssh/id_dsa.
  6. Your public key has been saved in /home/user/.ssh/id_dsa.pub.
  7. The key fingerprint is:
  8. ad:98:43:13:c9:ea:66:8e:d0:d9:66:59:d8:3a:f7:29
  9. The key's randomart image is:
  10. +--[ DSA 1024]----+
  11. | |
  12. | . . |
  13. | + |
  14. | + . . |
  15. | o = S . |
  16. | . + = + . |
  17. |. o @ = . |
  18. | . B oEo . |
  19. | . . .o |
  20. +-----------------+

you will get 2 files id_dsa and id_dsa.pub use scp or other utility to copy file to your server

  1. scp ~/.ssh/id_dsa.pub user@host:~/.ssh/

On your server

Add the new key to the file ~/.ssh/authorized_keys.

  1. cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

Finally change the access modes;

  1. chmod 600 ~/.ssh/authorized_keys
  2. chmod 700 ~/.ssh

Verify that access mode is correct for ~

  1. ls -ld ~

if not, you can use

  1. chmod 700 ~

to correct your home access.

Logout and login again

发表评论

表情:
评论列表 (有 0 条评论,205人围观)

还没有评论,来说两句吧...

相关阅读