Centos6.6升级ssh5.3版本到ssh8.3版本

下载所需要的源码包:

]#wget https://files-cdn.cnblogs.com/files/luckjinyan/zlib-1.2.11.tar.gz

]#wget https://files-cdn.cnblogs.com/files/luckjinyan/openssh-8.3p1.tar.gz

]#wget https://files-cdn.cnblogs.com/files/luckjinyan/openssl-1.1.1g.tar.gz

备份当前openssh

# cp/etc/ssh /etc/ssh.bak

# cp /etc/init.d/sshd /etc/init.d/sshd.abk

卸载旧的版本

# rpm -e –nodeps openssh-xxx(使用这条命令逐个卸载)

rpm -e --nodeps openssh-askpass-5.3p1-104.el6.x86_64

rpm -e --nodeps openssh-server-5.3p1-104.el6.x86_64

rpm -e --nodeps openssh-5.3p1-104.el6.x86_64

rpm -e --nodeps openssh-clients-5.3p1-104.el6.x86_64

卸载时报错,解决:

rpm -e --noscripts openssh-server-5.3p1-104.el6.x86_64

配置阿里yum源

curl -O http://mirrors.aliyun.com/repo/Centos-6.repo

curl -O http://mirrors.aliyun.com/repo/epel-6.repo

yum clean all && yum makecache

yum -y install gcc gcc-c++ vim pam* openssl-devel   (先安装要使用的工具)

注:pam*测试时未安装    若安装在进行openssh配置时需加上--with-pam=enable

解压   (-C 可以指定解压到指定的目录)

]#tar zxf zlib-1.2.11.tar.gz

]#tar zxf openssl-1.1.1g.tar.gz

]#tar zxf openssh-8.3p1.tar.gz

编译安装zlib

cd zlib-1.2.11

./configure --prefix=/usr/local/zlib

make && make install

编译安装openssl

cd openssl-1.1.1g
./config --prefix=/usr/local/openssl -d shared
make && make install
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl  
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so  //目前发现这一步有错误,可不做
echo '/usr/local/openssl/lib' >> /etc/ld.so.conf
ldconfig -v
openssl version

安装openssh

cd openssh-8.3p1
./configure --prefix=/usr  --sysconfdir=/etc/ssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/openssl --with-md5-passwords
make && make install

sshd_config文件修改

echo 'PermitRootLogin yes' >>/usr/local/openssh/etc/sshd_config
 
echo 'PubkeyAuthentication yes' >>/usr/local/openssh/etc/sshd_config
 
echo 'PasswordAuthentication yes' >>/usr/local/openssh/etc/sshd_config
 
解===>>>
PermitRootLogin yes         #允许root认证登录
PasswordAuthentication yes  #允许密码认证

RSAAuthentication yes       #秘钥认证
PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys  #默认公钥存放的位置
 

备份原有文件,并将新的配置复制到指定目录

cp -p /root/openssh-8.3p1/contrib/redhat/sshd.init /etc/init.d/sshd

cp -p /root/openssh-8.3p1/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam(使用pam需拷贝)

启动sshd

service sshd restart
 
centos7可直接使用systemctl进行管理

查看信息版本

ssh -V   或者 sshd -v

ubuntu升级ssh到8.3版本

更改apt源为阿里源

vi /etc/apt/sources.list         添加以下内容

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

--------------------------------------------------------------------------------------------------------------------

更新一下apt库:

apt update

解压   (-C 可以指定解压到指定的目录)

]#tar zxf zlib-1.2.11.tar.gz

]#tar zxf openssl-1.1.1g.tar.gz

]#tar zxf openssh-8.3p1.tar.gz

安装gcc编译工具

apt-get install gcc make libpam0g-dev

编译zlib

./configure --prefix=/usr/local/zlib

make

make install

编译安装openssl

cd openssl-1.1.1g
./config --prefix=/usr/local/openssl -d shared
make && make install
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl  
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so  //目前发现执行这一步有错误,可跳过
echo "/usr/local/openssl/lib" > /etc/ld.so.conf.d/openssl.conf  //这一步与centos有一些区别
ldconfig  
openssl version    //查看版本

# 备份原openssh文件

mv /etc/ssh /etc/ssh.bak

mv /etc/init.d/ssh  /etc/init.d/ssh.bak

# 卸载原openssh

apt-get remove
openssh-server openssh-client

cd openssh-8.3p1

./configure
--prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib=/usr/local/zlib
--with-ssl-dir=/usr/local/openssl --with-privsep-path=/var/lib/sshd #需要指定openssl的安装路径和zlib的安装路径

make && make
install

1. 修改默认配置文件

根据之前配置修改,保证配置相同

2. 也可使用原来的配置文件

cd /etc/ssh

mv sshd_config sshd_config.default

cp ../ssh.old/sshd_config ./

# 使用原来的/etc/init.d/ssh

mv /etc/init.d/ssh.old /etc/init.d/ssh

# 取消注销指定服务

systemctl unmask ssh

# 重启服务

systemctl restart ssh

---------------------------------报错-------------------------------------------

# 报错  checking whether OpenSSL's PRNG is internally
seeded... yes

#      
configure: error: PAM headers not found

# 解决:ubuntu: apt-get install libpam0g-dev   centos: yum -y install pam-devel

---------------------------------报错-------------------------------------------------------------------

# 报错: Privilege
separation user sshd does not exist

vim /etc/passwd

sshd:x:74:74:Privilege-separated
SSH:/var/empty/sshd:/sbin/nologin

# 注册名:口令:用户标识号:组标识号:用户名:用户主目录:命令解释程序

# /etc/passwd文件是Linux/UNIX安全的关键文件之一.该文件用于用户登录时校验 用户的口令,当然应当仅对root可写.

--------------------------------------------------------------------------------------------------------

Centos6(限6版本) ssh升级到8.3p脚本(超菜的写法,大神勿看)

#!/bin/bash

curl -o /opt/zlib-1.2.11.tar.gz
http://www.zlib.net/zlib-1.2.11.tar.gz > /dev/null

if [ $? == '0' ]; then

echo "zlib源码包下载完成!!"

else

exit 1

fi

curl -o /opt/openssh-8.3p1.tar.gz
http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.3p1.tar.gz
>/dev/null

if [ $? == '0' ]; then

echo "openssh源码包下载完成!!"

else

exit 1

fi

curl -o /opt/openssl-1.1.1g.tar.gz https://www.openssl.org/source/openssl-1.1.1g.tar.gz  >/dev/null

if [ $? == '0' ]; then

echo "openssl源码包下载完成!!"

else

exit 1

fi

#rpm -q openssh > /dev/null &&
cat /etc/redhat-release |grep 6.* > /dev/null

if [ -d /etc/ssh ]; then

mv /etc/ssh /etc/ssh.bak

echo "备份ssh OK"

fi

if [ -f /etc/init.d/sshd ]; then

mv /etc/init.d/sshd /etc/init.d/sshd.bak

echo "备份sshd OK"

fi

rpm -qa |grep openssh-askpass >
/dev/null

if [ $? == '0' ]; then

rpm -e --nodeps
openssh-askpass-5.3p1-104.el6.x86_64 && echo "成功卸载openssh-askpass"

fi

rpm -qa |grep openssh-server > /dev/null

if [ $? == '0' ]; then

rpm -e --noscripts
openssh-server-5.3p1-104.el6.x86_64 && echo "成功卸载openssh-server"

fi

rpm -qa |grep openssh-5.3p1 > /dev/null

if [ $? == '0' ]; then

rpm -e --nodeps
openssh-5.3p1-104.el6.x86_64 && echo "成功卸载openssh-5.3p1"

fi

rpm -qa |grep openssh-clients >
/dev/null

if [ $? == '0' ]; then

rpm -e --nodeps openssh-clients-5.3p1-104.el6.x86_64
&& echo "成功卸载openssh-clients"

fi

curl -o /etc/yum.repos.d/Centos-6.repo
http://mirrors.aliyun.com/repo/Centos-6.repo >/dev/null  && echo "pull Centos-6.repo
yes"

curl -o /etc/yum.repos.d/epel-6.repo
http://mirrors.aliyun.com/repo/epel-6.repo >/dev/null  && echo "pull epel-6.repo
yes"

yum clean all > /dev/null && yum
makecache > /dev/null && echo "repo clan yes"

yum -y install gcc gcc-c++ vim pam*
openssl-devel > /dev/null

if [ $? == '0' ];then

echo "install依赖 yes"

else

exit 1

fi

tar zxf /opt/zlib-1.2.11.tar.gz -C /opt/
&& cd /opt/zlib-1.2.11 && ./configure --prefix=/usr/local/zlib
>/dev/null && make >/dev/null && make install >
/dev/null && echo "install zlib succeed"

if [ $? == '0' ];then

tar zxf
/opt/openssl-1.1.1g.tar.gz -C /opt/ && cd /opt/openssl-1.1.1g
&& ./config --prefix=/usr/local/openssl -d shared >/dev/null
&& make >/dev/null && make install >/dev/null

echo "install openssl succeed"

else

exit 1

fi

if [ $? == '0' ];then

mv /usr/bin/openssl /usr/bin/openssl.bak && mv
/usr/include/openssl /usr/include/openssl.bak && ln -s
/usr/local/openssl/bin/openssl /usr/bin/openssl && ln -s
/usr/local/openssl/include/openssl /usr/include/openssl

else

exit 1

fi

if [ $? == '0' ];then

echo '/usr/local/openssl/lib' >> /etc/ld.so.conf &&
ldconfig -v > /dev/null && echo $(openssl version)

else

exit 1

fi

if [ $? == '0' ];then

cd /opt/ && tar zxf openssh-8.3p1.tar.gz -C /opt/ && cd
openssh-8.3p1 && ./configure --prefix=/usr  --sysconfdir=/etc/ssh
--with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/openssl
--with-md5-passwords --with-pam=enable > /dev/null && make >
/dev/null && make install > /dev/null

echo "install openssh succeed"

else

exit 1

fi

echo 'PermitRootLogin yes'
>>/etc/ssh/sshd_config

echo 'PubkeyAuthentication yes'
>>/etc/ssh/sshd_config

echo 'PasswordAuthentication yes'
>>/etc/ssh/sshd_config

cp -p
/opt/openssh-8.3p1/contrib/redhat/sshd.init 
/etc/init.d/sshd

cp -p
/opt/openssh-8.3p1/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam

service sshd restart && ssh -V

******人生若只如初见******

Centos6.6x系统与unbutu18.04系统升级ssh到8.3版本的更多相关文章

  1. 如何开启Centos6.4系统的SSH服务

    无论是Centos6.4系统的虚拟电脑还是服务器,始终感觉直接在命令行中操作不方便:比如全选.复制.粘贴.翻页等等.比如服务器就需要在机房给服务器接上显示器.键盘才操作感觉更麻烦.所以就可借助SSH( ...

  2. Ubuntu12.04之SSH

    Ubuntu 12.04 关于SSH的知识 (1)安装完ubuntu系统12.04. (2)查看网络配置,输入命令ip addr后,显示有IP地址. (3)使用SSH终端工具Xshell连接系统,发现 ...

  3. Ubuntu 16.04修改ssh端口

    1 安装防火墙 sudo apt-get install ufw启用 sudo ufw enable sudo ufw default deny 作用:开启了防火墙并随系统启动同时关闭所有外部对本机的 ...

  4. secureCRT连接liunx(centos6.5)系统步骤以及碰见的问题

    1.首先安装secureCRT以及用vmware安装centos6.5系统,用vmware打开centos6.5系统 2.找到liunx系统的ip,在liunx终端用ifconfig找到ip如下图: ...

  5. 在VMware Workstation上安装CentOS6.5系统步

    在VMware Workstation上安装CentOS6.5系统步骤 听语音 | 浏览:147 | 更新:2016-07-28 15:45 | 标签:安装 虚拟机 CENTOS 1 2 3 4 5 ...

  6. 使用kvm虚拟出Centos6.5系统相关步骤

    使用kvm虚拟出Centos6.5系统相关步骤 kvm是啥东西,亲们自行百度哇,一两句话也说不清楚,直接进主题使用宿主机虚拟出一台centos6.5的系统,当然其他系统也可以的,考虑到企业常用服务器系 ...

  7. VMWARE虚拟机CentOS6.4系统使用主机无线网卡上网的三种方法介绍

    转自:http://www.jb51.net/network/98820.html 如何真正的实现VMWARE虚拟机CentOS6.4系统使用主机无线网卡上网   环境:WIN7旗舰版,台式机,U盘无 ...

  8. CentOS6.5系统挂载NTFS分区的移动硬盘 centos安装repoforge源(yum)

    CentOS6.5系统挂载NTFS分区的移动硬盘 作为IT的工作者,避免不了使用Linux系统,我现在使用的系统是CentOS6.5 X86_64位版本,但是插入NTFS移动硬盘没有办法识别.通过下面 ...

  9. Centos6.5系统关闭防火墙

    关闭Centos6.5系统防火墙步骤: 1.命令:service iptables stop //停止正在运行的防火墙服务 2.命令:chkconfig iptables off //永久关闭防火墙 ...

随机推荐

  1. 《Head First 设计模式》:模板方法模式

    正文 一.定义 模板方法模式在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中.模板方法使得子类可以在不改变算法结构的情况下,重新定义算法中的某些步骤. 要点: 模板方法定义了一个算法的步骤,每 ...

  2. 力扣Leetcode 面试题56 - I. 数组中数字出现的次数

    面试题56 - I. 数组中数字出现的次数 一个整型数组 nums 里除两个数字之外,其他数字都出现了两次.请写程序找出这两个只出现一次的数字.要求时间复杂度是O(n),空间复杂度是O(1). 示例 ...

  3. webpack做项目优化

    webpack优化 -- compression-webpack-plugin 开启gzip 打包的时候开启gzip可以大大减少体积,非常适合于上线部署.下面以vue-cli2.x项目为例,介绍如何在 ...

  4. vueRooter的总结

    这一周学习了Vue的脚手架的结构,最重要的router 该进行总结和回忆了. 1首先是router的安装,用npm命令npm install vue-router --save 2装完后,在main. ...

  5. Activiti7 网关(包含网关)

    什么是包含网关? 包含网关可以看做是排他网关和并行网关的结合体,和排他网关一样,你可以在外出顺序流上定义条件,包含网关会解析他们,但是主要的区别是包含网关可以选择多于一条顺序流,这和并行网关是一样的 ...

  6. KMP记录

    例题:luogu P3375 [模板]KMP字符串匹配 知识点:1.KMP模板,熟悉KMP 2.理解KMP过程:失配时,是从后缀转向前缀.即失配时,匹配串是从尾转到头继续匹配,被匹配串不改变. 3.注 ...

  7. JsonAnalyzer2 1.01版

    本版的改进主要在字符串的处理,前版不允许出现[]{},:等,现在都可以了,做出的修改主要在Lexer类,另外Token类增加1了下标,TreeBuilder类的不合语法处也做出一定修改. 测试用例:h ...

  8. SpringCloud Gateway高阶之Sentinel限流、熔断

    前言 为什么需要服务熔断和降级?微服务是当前业界的一大趋势,原理就是将单一职责的功能模块独立化为子服务,降低服务间的耦合,服务间互相调用.但是这样也会出现一些问题: 上图中大量微服务互相调用,存在大量 ...

  9. C#的TextBox的四种禁止编辑方法

    前言 一般而言,Textbox中有两个属性可以对其进行防止编辑的设定,这是最基础的知识,也是我要提出的前两种方法.而后两种方法实际为一种,但可以应用于不同环境中. 一.ReadOnly属性 这样设置, ...

  10. unittest单元测试执行用例的顺序

    打印结果如下: