確保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便可