openssh升级安装手册
一、安装telnet
安装telnet,为了防止升级中ssh连接中断,导致无法远程
1.启用telnet服务
service xinetd start
telnet服务开机启动
避免升级过程中服务器意外重启后无法远程登录系统
2.开启root登录
默认情况下是不允许root登陆的,如果一定需要root登陆
vi /etc/xinetd.d/telnet
将其中disable字段的yes改为no以启用telnet服务
mv /etc/securetty /etc/securetty.old
允许root用户通过telnet登录
3.重启telnet服务
service xinetd restart
4.测试telnet连接ssh
telnet xxx.xxx.xxx.xxx
不用跟端口
二、安装openssh新版本
1.备份
mv /etc/ssh /etc/ssh.old
mv /etc/init.d/sshd /etc/init.d/sshd.old
pm -qa |grep openssl #检查openssl是否>=1.0.1如果不是需要重新安装openssl
2.查看已安装的rpm文件
[root@seth-node1 ~]# rpm -qa | grep openssh
openssh-5.3p1-94.el6.x86_64
openssh-askpass-5.3p1-94.el6.x86_64
openssh-clients-5.3p1-94.el6.x86_64
openssh-server-5.3p1-94.el6.x86_64
3.卸载当前ssh
然后分别执行,用查到的文件名替换,注意版本号
rpm -e --nodeps openssh-5.3p1-94.el6.x86_64
rpm -e --nodeps openssh-clients-5.3p1-94.el6.x86_64
rpm -e --nodeps openssh-askpass-5.3p1-94.el6.x86_64
rpm -e --noscripts openssh-server-5.3p1-94.el6.x86_64
4.下载安装包
1)下载页
2)下载链接
https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-7.6p1.tar.gz
这里用的openssh-7.6p1.tar.gz版本
3)下载并解压
wget https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-7.6p1.tar.gz
tar -zxvf openssh-7.6p1.tar.gz
cd openssh-7.6p1
5.编译安装
1)编译前先安装依赖包
yum install zlib-devel openssl-devel pam-devel gcc -y
2)编译安装
./configure --prefix=/usr/local/openssh/ \
--sysconfdir=/etc/ssh --with-md5-passwords \
--with-pam --with-zlib --with-openssl-includes=/usr \
--with-privsep-path=/var/lib/sshd
make
make install
3) 覆盖文件
cp -p contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
chkconfig --add sshd
cp sshd_config /etc/ssh/sshd_config
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp ssh-keygen /usr/bin/
cp ssh /usr/bin/ssh
三、重启服务
service sshd restart
如果提示
[root@seth-node1 openssh-7.6p1]# service sshd restart
Stopping sshd: [ OK ]
/sbin/restorecon: lstat(/etc/ssh/ssh_host_key.pub) failed: No such file or directory
Starting sshd: [ OK ]
到/etc/rc.d/init.d/sshd把这个文件的检查删掉
42 if [ -x /sbin/restorecon ]; then
43 /sbin/restorecon /etc/ssh/ssh_host_key.pub
44 /sbin/restorecon /etc/ssh/ssh_host_rsa_key.pub
45 /sbin/restorecon /etc/ssh/ssh_host_dsa_key.pub
46 /sbin/restorecon /etc/ssh/ssh_host_ecdsa_key.pub
47 fi
删掉43行即可
重启后测试连接
四、关闭telnet服务
如果条件允许,可以重启下服务器验证下是否仍然可以ssh登陆
然后关闭telnet服务
mv /etc/securetty.old /etc/securetty
chkconfig xinetd off
service xinetd stop
616



被折叠的 条评论
为什么被折叠?



