linux centOS配置ssh远程登录

  1. ssh远程登录
    1. 公钥和私钥的生成

进入到/etc/ssh目录下:cd /etc/ssh

生成公私钥:ssh-keygen -t rsa -P root123 -f root -C ‘my root key’

(root123是登录密码、root是生成的文件名、my root key是登录注释)

    1. 将公钥部署到服务器

执行:cat root.pub >> ~/.ssh/authorized_keys

将root和root.pub文件拷贝到本地电脑上(登录验证时用的文件是root.pub)

    1. 更改服务器配置

修改sshd_config文件:vi /etc/ssh/sshd_config

修改文件内容:RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile      /root/.ssh/authorized_keys

PasswordAuthentication no

重启ssh服务:service sshd restart

              systemctl restart sshd.service(centOS7重启方式)

你可能感兴趣的:(linux,linux)