CentOS升级openssh8.9


安装telnet,切换为telnet登录,确保在安装ssh时能稳定连接
[root@localhost ~]# yum install xinetd telnet-server -y
[root@localhost ~]# systemctl enable xinetd 
[root@localhost ~]# systemctl enable telnet.socket
[root@localhost ~]# systemctl start telnet.socket
[root@localhost ~]# systemctl start xinetd
#安装相关依赖,编译安装必备
[root@localhost ~]# yum install  -y gcc gcc-c++ glibc make autoconf pcre-devel  pam-devel
[root@localhost ~]# yum install  -y pam* zlib*

查看当前版本
[root@localhost ~]# ssh -V
OpenSSH_8.0p1, OpenSSL 1.0.2r  26 Feb 2019

3.更新openssl
[root@localhost ~]# yum update openssl
4.安装openssh

(1,一定要注意提到的安装路径,还要修改/etc/init.d/sshd配置文件中找到这行".: /etc/rc.d/init.d/functions" 把其中的":"给去了 ;

2,下文#配置 步骤如果出现“OpenSSL library not found” 执行命令:CCFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure 即可

3,下文#配置允许root登录 步骤生成的配置文件在/usr/local/openssh-8.9p1/sshd_config)

[root@localhost ~]# systemctl status sshd   #查看sshd
[root@localhost ~]# systemctl stop sshd    #停止sshd
[root@localhost ~]# rm -rf /etc/ssh/ #清理配置文件
#查看当前openssh
[root@localhost ~]# rpm  -qa |grep  openssh
openssh-clients-6.6.1p1-31.el7.x86_64
openssh-server-6.6.1p1-31.el7.x86_64
#删除当前openssh
[root@localhost ~]# yum erase -y openssh-clients openssh-server openssh 
#安装openssh
[root@localhost ~]# yum install -y pam-devel #安装pam
[root@localhost ]# tar xf openssh-8.9p1.tar.gz #解压openssh8.9
[root@localhost ]# cd openssh-8.9p1 
#配置
./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/include --with-ssl-dir=/usr/local/bin --with-zlib --with-md5-passwords --with-pam 
## --prefix=/usr/ 这里还是指定一下安装的目录路径;
#--sysconfdir=/etc/ssh 这里指定的配置文件的目录路径; 
#--with-openssl-includes=/usr/local/include 看上面讲一下;
# --with-ssl-dir=/usr/local/openssl 看上面讲一下;后面参数不需要调整,写上就可以啦
#安装
make && make install
[root@localhost openssh-8.9p1]# echo $? 检查,结果为0就好了
0
[root@localhost openssh-8.9p1]# cd contrib/redhat 在解压的openssh目录找到启动文件
[root@localhost redhat]# ll
总用量 48
-rw-r--r-- 1 confluence confluence    58 2月  23 19:31 gnome-ssh-askpass.csh
-rw-r--r-- 1 confluence confluence    70 2月  23 19:31 gnome-ssh-askpass.sh
-rw-r--r-- 1 confluence confluence 30082 2月  23 19:31 openssh.spec
-rwxr-xr-x 1 confluence confluence  1721 2月  23 19:31 sshd.init
-rw-r--r-- 1 confluence confluence   277 2月  23 19:31 sshd.pam
[root@localhost redhat]# cp -a sshd.init /etc/init.d/sshd
cp:是否覆盖"/etc/init.d/sshd"?#回车
#启动ssh
[root@localhost redhat]# systemctl start sshd
Warning: sshd.service changed on disk. Run 'systemctl daemon-reload' to reload units. #警告了,操作下
[root@localhost redhat]# systemctl daemon-reload #按照上面提示操作
[root@localhost redhat]# systemctl start sshd #启动
#顺便设置一下开机自动启动
#常规的 systemctl 设置会给予一个提示,命令被重定向了,那么就使用提示给的命令
[root@localhost redhat]# systemctl enable sshd
sshd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig sshd on
#再次设置开机启动
#下面显示2、3、4、5是on就可以,其数字代表启动级别
[root@localhost redhat]# /sbin/chkconfig sshd on
[root@localhost redhat]# chkconfig --list sshd

注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 
      如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
      欲查看对特定 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

sshd            0:关 1:关 2:开 3:开 4:开 5:开 6:关
#配置允许root登录
[root@localhost redhat]# vim /etc/ssh/sshd_config
#在文件中加入下面内容
permitRootlogin yes
#重启sshd
[root@localhost redhat]# systemctl restart sshd
[root@localhost redhat]# systemctl status sshd
● sshd.service - SYSV: OpenSSH server daemon
   Loaded: loaded (/etc/rc.d/init.d/sshd; bad; vendor preset: enabled)
   Active: active (running) since 四 2022-04-07 20:27:03 CST; 25s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 25647 ExecStop=/etc/rc.d/init.d/sshd stop (code=exited, status=0/SUCCESS)
  Process: 25650 ExecStart=/etc/rc.d/init.d/sshd start (code=exited, status=0/SUCCESS)
 Main PID: 25656 (sshd)
   CGroup: /system.slice/sshd.service
           ├─13677 sshd: root@notty
           ├─13679 /usr/libexec/sftp-server
           ├─13785 /usr/libexec/sftp-server
           └─25656 sshd: /usr/sbin/sshd [listener] 0 of 10-100 startups

4月 07 20:27:03 localhost.localdomain systemd[1]: Starting SYSV: OpenSSH server daemon...
4月 07 20:27:03 localhost.localdomain sshd[25656]: Server listening on 0.0.0.0 port 22.
4月 07 20:27:03 localhost.localdomain sshd[25656]: Server listening on :: port 22.
4月 07 20:27:03 localhost.localdomain sshd[25650]: Starting sshd:[  确定  ]
4月 07 20:27:03 localhost.localdomain systemd[1]: Started SYSV: OpenSSH server daemon.
#查看版本
[root@localhost redhat]# ssh -V
OpenSSH_8.9p1, OpenSSL 1.0.2k-fips  26 Jan 2017

 启动sshd过程中会出现各种奇葩问题,多用命令systemctl status sshd去看问题

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值