1. 安裝openssh-server
yum install -y openssl openssh-server
2. 修改配置文件
用vim打開配置文件/etc/ssh/sshd_config
將上圖的PermitRootLogin,RSAAuthentication,PubkeyAuthentication的設置打開。
啟動ssh的服務:
systemctl start sshd.service
設置開機自動啟動ssh服務
systemctl enable sshd.service
設置文件夾~/.ssh的訪問權限:
$ cd ~
$ chmod 700 .ssh
$ chmod 600 .ssh/*
$ ls -la .ssh
total 16
drwx------. 2 root root 58 May 15 00:23 .
dr-xr-x---. 8 root root 4096 May 15 00:26 ..
-rw-------. 1 root root 403 May 15 00:22 authorized_keys -rw-------. 1 root root 1766 May 15 00:21 id_rsa -rw-------. 1 root root 403 May 15 00:21 id_rsa.pub
authorized_keys文件存儲的是客戶端的公共密鑰。