Linux下配置免密登录!

Posted 无处安放的青春

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下配置免密登录!相关的知识,希望对你有一定的参考价值。

ssh-keygen  产生公钥与私钥对.
ssh-copy-id 将本机的公钥复制到远程机器的authorized_keys文件中,ssh-copy-id也能让你有到远程机器的home, ~./ssh , 和 ~/.ssh/authorized_keys的权利

第一步:在本地机器上使用ssh-keygen产生公钥私钥对
  1. [email protected]$ [Note: You are on local-host here]
  2. [email protected]$ ssh-keygen
  3. Generating public/private rsa key pair.
  4. Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
  5. Enter passphrase (empty for no passphrase): [Press enter key]
  6. Enter same passphrase again: [Pess enter key]
  7. Your identification has been saved in /home/jsmith/.ssh/id_rsa.
  8. Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
  9. The key fingerprint is:
  10. 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 [email protected]
第二步:用ssh-copy-id将公钥复制到远程机器中
  1. [email protected]$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
  2. [email protected]‘s password:
  3. Now try logging into the machine, with "ssh ‘remote-host‘", and check in:
  4. .ssh/authorized_keys
  5. to make sure we haven‘t added extra keys that you weren‘t expecting.

注意: ssh-copy-id 将key写到远程机器的 ~/ .ssh/authorized_key.文件中

第三步: 登录到远程机器不用输入密码
  1. [email protected]$ ssh remote-host
  2. Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
  3. [Note: SSH did not ask for password.]
  4. [email protected]$ [Note: You are on remote-host here]

 

另外:

  1. ssh-copy-id -u wyz -i ~/.ssh/id_rsa.pub [email protected]_host

上述是给wyz用户赋予无密码登陆的权利

以上是关于Linux下配置免密登录!的主要内容,如果未能解决你的问题,请参考以下文章

linux下配置远程免密登录

Linux下配置ssh免密远程登录

linux配置了免密,如何不使用免密登录

Linux 配置SSH免密登录

linux 免密登录

Linux下配置免密登录!