随笔 - 23  文章 - 2 评论 - 2 阅读 - 51469
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

此处升级操作的原则是保留系统原有ssh服务,新安装高版本ssh服务

1、下载openssh源码包

http://www.openssh.com/portable.html

2、安装
#tar zxvf openssh-7.2p2.tar.gz
#cd openssh-7.2p2
#./configure --prefix=/usr/local/openssh --sysconfdir=/usr/local/openssh/etc --with-pam --with-ssl-dir=/usr/local/openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib
#make && make install
3、配置启动脚本和配置文件
cp /etc/init.d/sshd /ghca/bak/sshd #备份旧版sshd启动脚本
cp /ghca/openssh-7.2p2/contrib/redhat/sshd.init /etc/init.d/sshd ##拷贝新版启动脚本
vi /etc/init.d/sshd #编辑启动脚本

主要将以下内容

SSHD=/usr/sbin/sshd
/usr/bin/ssh-keygen -A
/sbin/restorecon /etc/ssh/ssh_host_key.pub
/sbin/restorecon /etc/ssh/ssh_host_rsa_key.pub
/sbin/restorecon /etc/ssh/ssh_host_dsa_key.pub
/sbin/restorecon /etc/ssh/ssh_host_ecdsa_key.pub

修改为:

SSHD=/usr/local/openssh/sbin/sshd
/usr/local/openssh/bin/ssh-keygen -A
/sbin/restorecon /usr/local/openssh/etc/ssh_host_key.pub
/sbin/restorecon /usr/local/openssh/etc/ssh_host_rsa_key.pub
/sbin/restorecon /usr/local/openssh/etc/ssh_host_dsa_key.pub
/sbin/restorecon /usr/local/openssh/etc/ssh_host_ecdsa_key.pub

注意:此时/usr/local/openssh/etc目录下可能没有那几个key,但是也可以先这样修改,具体这个几个key的用法还没做研究。

4、配置公私钥文件
#cd /root/.ssh
#/usr/local/openssh/bin/ssh-keygen -t rsa  #生成公私钥对
#cat id_rsa.pub >> authorized_keys  #写入公钥到服务器认证文件
5、将私钥文件下载保存至本地
/root/.ssh/id_rsa
6、重启sshd服务
/etc/init.d/sshd restart
7、配置本地SecureCRT并登录服务器
将对应服务器登录session配置中去掉密码验证,并配置公钥路径,如下图:

 

注意:openssh7.0以后就不允许root使用交互模式密码登录了,必须使用公钥登录,普通账号可以使用密码方式登录。

* The default for the sshd_config(5) PermitRootLogin option has
   changed from "yes" to "prohibit-password".
 * PermitRootLogin=without-password/prohibit-password now bans all
   interactive authentication methods, allowing only public-key,
   hostbased and GSSAPI authentication (previously it permitted
   keyboard-interactive and password-less authentication if those
   were enabled).

详见:http://bluereader.org/article/66465824?qqdrsign=07af0

posted on   lzc_jack  阅读(6929)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示