1.查看当前版本
ssh -V
2.安装 xinetd服务
yum -y install xinetd
3.安装telnet 服务端 客户端
yum -y install telnet telnet-server
4.启动
systemctl start xinetd
systemctl start telnet.socket
vim /etc/pam.d/remote ##注释一行,否则无法远程
自行百度,我也忘记了
一定要保证使用telnet可以访问服务器再升级sshd,防止升级失败无法访问服务器;
5.防火墙
iptables -I INPUT -s 172.16.8.22 -ptcp --dport 23 -j ACCEPT
iptables -nL --line-number
iptables -D INPUT 1
6.下载安装包
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.2p1.tar.gz(https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.0p1.tar.gz)
- 装编译环境
yum install -y pam* zlib* openssl-devel gcc make
- 备份
cp -r /etc/ssh /tmp/
8.编译
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-zlib --with-pam --without-openssl-header-check --with-ssl-dir=/usr/local/ssl --with-privsep-path=/var/lib/sshd
make
rpm -e --nodeps rpm -qa | grep openssh
rm -rf /etc/ssh/*
make install
10
cp -a /etc/init.d/sshd /etc/init.d/sshd20230725
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
chkconfig sshd on
chkconfig --add sshd
systemctl enable sshd
systemctl restart sshd
systemctl stop xinetd
systemctl stop telnet.socket
服务器提示权限拒绝:
编辑文件
vim /etc/ssh/sshd_config
最后一行添加:
HostKeyAlgorithms ssh-rsa,ssh-dss
重启ssh服务
systemctl restart sshd
记得一定要设置允许root远程登入!!!
完成!