本帖最后由 469327849 于 2016-4-18 15:07 编辑
1、关闭selinux
# vim /etc/selinux/config
把SELINUX=enforce改为SELINUX=disabled
保存退出重启。
2、创建.ssh目录,修改权限为600
#mkdir .ssh
#chmod 600 .ssh
3、在.ssh中创建authorized_keys,修改权限为700
# touch authorized_keys
# chmod 700 authorized_keys
3、使用putty key generator生成密钥对,如图
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/ed99f234-11af-4ca8-a19c-e846e8e62ea0.png
a)使用generate生成密钥,快速移动鼠标,加快生成速度
b)将2处的公钥拷贝,黏贴到authorized_keys
c)设置密钥的密码
d)保存私钥
4、修改sshd_conf
# vim /etc/ssh/sshd_config
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/779abab4-0842-4919-a441-c04ca34383aa.png
去掉前面3行的#号
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/87085c5b-d36e-4129-9f44-2efdf2aa3cbc.png
并把PasswordAuthentication yes改为PasswordAuthentication no
5、重启sshd
# service sshd restart
6、putty选择私钥登陆
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/b4879ea8-6915-40b9-abf7-bbcc90d47c82.png
7、登陆后
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/8a929b60-cb9c-4d8e-ad00-f30ee5ce40b8.png
提示你使用设置密钥的密码登陆,表示设置密钥登陆成功了。
========================================================
两台linux机子使用密钥互相登陆
1、A,B两台机子都输入ssh-keygen -t rsa,然后一直回车
2、修改两台机子.ssh的权限为600
# chmod 600 .ssh
3、把A,B两台机子的id_rsa.pub修改为authorized_keys,并修改权限为700
# mv id_rsa.pub authorized_keys
# chmod 700 authorized_keys
4、把A机子authorized_keys的内容追加到B机子上,同时也把B机子authorized_keys的内容追加到A机子上
5、两台机子上都修改sshd_conf
# vim /etc/ssh/sshd_config
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/779abab4-0842-4919-a441-c04ca34383aa.png
去掉前面3行的#号
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/87085c5b-d36e-4129-9f44-2efdf2aa3cbc.png
并把PasswordAuthentication yes改为PasswordAuthentication no
6、重启sshd
# service sshd restart
7、互相登录,不解释看图
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/5bc87b7f-7d18-41c1-bad5-6022a677aebe.png
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/d3181750-8085-47aa-a21d-64c6ddafe8e3.png
1、关闭selinux
# vim /etc/selinux/config
把SELINUX=enforce改为SELINUX=disabled
保存退出重启。
2、创建.ssh目录,修改权限为600
#mkdir .ssh
#chmod 600 .ssh
3、在.ssh中创建authorized_keys,修改权限为700
# touch authorized_keys
# chmod 700 authorized_keys
3、使用putty key generator生成密钥对,如图
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/ed99f234-11af-4ca8-a19c-e846e8e62ea0.png
a)使用generate生成密钥,快速移动鼠标,加快生成速度
b)将2处的公钥拷贝,黏贴到authorized_keys
c)设置密钥的密码
d)保存私钥
4、修改sshd_conf
# vim /etc/ssh/sshd_config
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/779abab4-0842-4919-a441-c04ca34383aa.png
去掉前面3行的#号
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/87085c5b-d36e-4129-9f44-2efdf2aa3cbc.png
并把PasswordAuthentication yes改为PasswordAuthentication no
5、重启sshd
# service sshd restart
6、putty选择私钥登陆
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/b4879ea8-6915-40b9-abf7-bbcc90d47c82.png
7、登陆后
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/8a929b60-cb9c-4d8e-ad00-f30ee5ce40b8.png
提示你使用设置密钥的密码登陆,表示设置密钥登陆成功了。
========================================================
两台linux机子使用密钥互相登陆
1、A,B两台机子都输入ssh-keygen -t rsa,然后一直回车
2、修改两台机子.ssh的权限为600
# chmod 600 .ssh
3、把A,B两台机子的id_rsa.pub修改为authorized_keys,并修改权限为700
# mv id_rsa.pub authorized_keys
# chmod 700 authorized_keys
4、把A机子authorized_keys的内容追加到B机子上,同时也把B机子authorized_keys的内容追加到A机子上
5、两台机子上都修改sshd_conf
# vim /etc/ssh/sshd_config
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/779abab4-0842-4919-a441-c04ca34383aa.png
去掉前面3行的#号
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/87085c5b-d36e-4129-9f44-2efdf2aa3cbc.png
并把PasswordAuthentication yes改为PasswordAuthentication no
6、重启sshd
# service sshd restart
7、互相登录,不解释看图
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/5bc87b7f-7d18-41c1-bad5-6022a677aebe.png
http://file:///G:/My%20Knowledge/temp/6fc3ef06-c1d6-40cc-8b14-72d0e5012fb1_4_files/d3181750-8085-47aa-a21d-64c6ddafe8e3.png
编辑回复