標籤:
vim /etc/ssh/sshd_config, 下面三行去掉注釋符號#RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keysmkdir -p ~/.sshchmod 700 ~/.ssh
產生公開金鑰和私密金鑰
[[email protected] .ssh]# cd ~/.ssh[[email protected] .ssh]# ssh-keygen -t rsaGenerating 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:82:32:47:81:df:8e:6e:0f:ce:ee:a7:fd:f9:6e:52:47 [email protected]The key‘s randomart image is:+--[ RSA 2048]----+| .. || . . || ... || .... E || o oo. S . || +. .. . . || .. . . || ooo. ... || +*+o.o=o |+-----------------+[[email protected] .ssh]#
配置
[[email protected] .ssh]# cat id_rsa.pub > authorized_keys[[email protected] .ssh]# chmod 600 authorized_keys[[email protected] .ssh]# lltotal 12-rw-------. 1 root root 408 Jul 11 23:02 authorized_keys-rw-------. 1 root root 1675 Jul 11 22:58 id_rsa-rw-r--r--. 1 root root 408 Jul 11 22:58 id_rsa.pub
下載id_rsa到本地,用pyTTYgen轉換為.ppk檔案,配置到putty中,配置登陸使用者名稱root
login as: rootServer refused our key[email protected]192.168.88.133‘s password:
登陸失敗。。。需要disable selinux
[[email protected] ~]# getenforceEnforcing[[email protected] ~]# setenforce 0[[email protected] ~]# getenforcePermissive[[email protected] ~]#
再次嘗試成功!
Using username "root".Authenticating with public key "imported-openssh-key"Last login: Mon Jul 11 23:27:25 2016 from 192.168.88.1[[email protected] ~]#
永久disable selinux
/etc/selinux/config,修改SELINUX=disabled 或者permissive
centos 配置puTTY rsa自動登入