1.查看openssh相关服务
rpm -qa openssh*
2.卸载ssh
yum remove openssh*
3.安装ssh服务端与客户端
yum install openssh-server openssh-clients
如果yum仓库中没有,则配置源
阿里云源地址:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
4.编辑ssh配置文件
vim /etc/ssh/sshd_config
改动内容:
如果要打开root远程功能则配置PermitRootLogin,反之则配置为no或者注释掉
Port 22
PermitRootLogin yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
5.启动与开机自启服务
systemctl start sshd
systemctl enable sshd