linux ssh秘钥配置登录
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux ssh秘钥配置登录相关的知识,希望对你有一定的参考价值。
#ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 2a:ad:45:20:74:8b:bf:8f:c4:a8:6e:af:46:50:6b:ea [email protected] The key‘s randomart image is: +--[ RSA 2048]----+ | . . | | ..o . | | .o.o | |. oo . | |.o . . S | |.. o + . | |o . = + | | E . * | |=oo.o . | +-----------------+ #ssh-copy-id -i ~/.ssh/id_rsa.pub 12.0.0.16 [email protected]‘s password: Now try logging into the machine, with "ssh ‘12.0.0.16‘", and check in: .ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting. [CCDT-QH-业务导航-1-root-<ccdt>]~#ssh 12.0.0.16 Last login: Sat Aug 5 10:27:32 2017 from 12.0.0.15 [CCDT-QH-业务导航-2-root-<~>]~#
#ssh-keygen -t rsa 三个回车生成密钥对 ###生成rsa密钥对,默认保存在~/.ssh/{id_rsa,id_rsa.pub} ###id_rsa私钥自己保存的 id_rsa.pub公钥被连主机保存的 #ssh-copy-id -i ~/.ssh/id_rsa.pub 12.0.0.16 ###将公钥copy到将要登录主机(12.0.0.16)中,默认(此位置是ssh配置文件中定义的)位置为~/.ssh/authorized_keys文件中 无需密码登录执行scp ssh 完成。。
服务器配置完整的步骤应该是:
(1)生成密钥公钥copy到服务器上,私钥保存在本地
(2)配置hosts.allow hosts.deny指名ssh允许链接的白名单
(3)禁止使用密码登录
(4)(可选)禁止root用户远程登录
go go go。。。
本文出自 “坚持。。。” 博客,请务必保留此出处http://qchanblog.blog.51cto.com/9686614/1953831
以上是关于linux ssh秘钥配置登录的主要内容,如果未能解决你的问题,请参考以下文章