一:先配置ssh配置文件
# vi /etc/ssh/sshd_config
做如下修改:
PasswordAuthentication no (关闭口令认证)
PubkeyAuthentication yes (开启公钥认证)
AuthorizedKeysFile .ssh/authorized_keys (认证公钥文件位置)
PermitRootLogin yes(改为no的话,root就不能用ssh登陆了,所以必须创建至少一个一般权限的如:user1,lxp )
:简洁的配置文件
#vi /etc/ssh/sshd_config
Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
KeyRegenerationInterval 3600
ServerKeyBits 768
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 600
PermitRootLogin yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
RhostsAuthentication no
IgnoreRhosts yes
HostbasedAuthentication no
PasswordAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
MaxStartups 20
Subsystem sftp /usr/libexec/openssh/sftp-server
# /etc/init.d/sshd restart
二:创建密码密匙
不同我用户,先登陆到不同的用户,于运行以下命令
# ssh-keygen -b 1024 -t rsa
# cat id_rsa.pub >authorized_keys
# ls
authorized_keys id_rsa id_rsa.pub
三:把 id_rsa , id_rsa.pub 下载下来给用户
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16111659/viewspace-669943/ ,如需转载,请注明出处,否则将追究法律责任。