确保CentOS7安装了 openssh-server,在终端中输入 yum list installed | grep openssh-serverhtml
此处显示已经安装了 openssh-server,若是又没任何输出显示表示没有安装 openssh-server,经过输入 yum install openssh-serverlinux
找到了 /etc/ssh/ 目录下的sshd服务配置文件 sshd_config,用Vim编辑器打开,将文件中,关于监听端口、监听地址前的 # 号去除shell
而后开启容许远程登陆centos
最后,开启使用用户名密码来做为链接验证ssh
开启 sshd 服务,输入 sudo service sshd start编辑器
检查 sshd 服务是否已经开启,输入ps -e | grep sshdcentos7
或者输入netstat -an | grep 22 检查 22 号端口是否开启监听spa
添加开启启动rest
chkconfig sshd on
sudo systemctl stop firewalld.service sudo systemctl disable firewalld.service
vi /etc/ssh/sshd_config
查找RSAAuthentication、StrictModes、PubkeyAuthentication、AuthorizedKeysFile把所在行修改成:code
RSAAuthentication yes StrictModes no PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys
重启SSH服务
systemctl restart sshd.service #而后用xshell或者linux本身的keygen生成私钥和公钥,把公钥拷贝到/root/.ssh/authorized_keys便可