首页 > 代码库 > linux ssh密钥登录

linux ssh密钥登录

ssh 端口:tcp 22

 

建议创建普遍用户登录管理

创建用户

useradd user

设置密码

passwd user


创建密钥

ssh-keygen -t rsa -P ‘‘


创建公钥

cat ~/.ssh/id_rsa.pub >~/.ssh/authorized_keys

chmod 600 ~/.ssh/authorized_keys


私钥

id_rsa 


ssh配置文件

vi /etc/ssh/sshd_conf

--------------------------------

PermitRootLogin no                // 改为no 禁止root用户登录

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile      .ssh/authorized_keys

PasswordAuthentication no         // 改为 no 禁止口令登录

--------------------------------

去掉#
service sshd restart


本地服务器上将authorized_keys复制到远程服务器上

scp ~/.ssh/authorized_keys 10.10.10.10:/home/user/.ssh/



本文出自 “Shell” 博客,请务必保留此出处http://zhizhimao.blog.51cto.com/3379994/1946301

linux ssh密钥登录