1.更新yum
yum update
2.安装openssh和openssh-server
sudo yum install openssh
sudo yum install openssh-server
卸载
yum remove openssh
yum remove openssh-server
3.配置openssh-server
生成秘钥对,保持默认配置即可。
ssh-keygen
编辑/etc/ssh/sshd_config文件
vim /etc/ssh/sshd_config
修改配置文件
设置ssh,打开登录功能,允许root通过 SSH 登录
PubkeyAuthentication yes
PermitRootLogin yes
设置系统开机自启openssh-server,开启openssh-server
systemctl enable sshd ---开机自动启动
systemctl disable sshd ---禁止开机自动启动(可选)
systemctl start sshd ---启动服务
systemctl stop sshd ---停止服务
查看是否打开22端口
netstat -antp | grep sshd