源碼包升級ssl/ssh

參考:

http://www.2cto.com/os/201510/445119.html

http://www.cnblogs.com/jyzhao/p/5817199.html#2

本文參考以上兩位大神的博客,結合實際安裝所遇到的問題編寫。

一、準備工作

-操作系統:

centos6.5 64位

-升級前版本:

[root@localhost ~]# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
[root@localhost ~]# ssh -V
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb2013

-升級後版本:

openssl-1.0.2j.tar.gz
openssh-7.3p1.tar.gz

-備份ssh配置文件:

[root@localhost ~]# tar zcvf/etc/ssh.tar.gz /etc/ssh/
tar: 從成員名中刪除開頭的“/”
/etc/ssh/
/etc/ssh/ssh_host_dsa_key
/etc/ssh/ssh_host_dsa_key.pub
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_config
/etc/ssh/ssh_host_key.pub
/etc/ssh/moduli
/etc/ssh/ssh_host_key
/etc/ssh/ssh_host_rsa_key.pub
/etc/ssh/sshd_config

-如果系統沒有其他用戶,新建一個普通用戶

[root@localhost ~]# useradd u1
[root@localhost ~]# passwd u1
更改用戶 u1 的密碼 。
新的 密碼:
無效的密碼: WAY 過短
無效的密碼: 過於簡單
重新輸入新的 密碼:
passwd: 所有的身份驗證令牌已經成功更新。

-將源碼包上傳至服務器/usr/src目錄下

[root@localhost src]# ll /usr/src/
總用量 6680
drwxr-xr-x. 2 root root    4096 9月  23 2011 debug
drwxr-xr-x. 3 root root    4096 9月  25 19:35 kernels
-rw-r--r--. 1 root root 1522617 12月  2 12:14 openssh-7.3p1.tar.gz
-rw-r--r--. 1 root root 5307912 12月  2 12:46openssl-1.0.2j.tar.gz

 

 

二、升級OpenSSL,並刪除老版本

1、刪除舊版本
[root@localhost src]# rpm -qa | grepopenssl
openssl-1.0.1e-15.el6.x86_64
openssl-devel-1.0.1e-15.el6.x86_64
[root@localhost src]# rpm -e `rpm -qa |grep openssl` --allmatches –nodeps
[root@localhost src]# openssl version
-bash: /usr/bin/openssl: 沒有那個文件或目錄
2、安裝openssl

-參考:

http://www.linuxfromscratch.org/blfs/view/svn/postlfs/openssl.html

-解包:

[root@localhost src]# tar zxfopenssl-1.0.2j.tar.gz
[root@localhost src]# cd openssl-1.0.2j

-配置,編譯

[root@localhost openssl-1.0.2j]# ./config--prefix=/usr         \
>          --openssldir=/etc/ssl \
>          --libdir=lib          \
>          shared                \
>          zlib-dynamic &&
> make depend           &&
> make
-安裝:
[root@localhost openssl-1.0.2j]# makeMANDIR=/usr/share/man MANSUFFIX=ssl install &&
> install -dv -m755/usr/share/doc/openssl-1.0.2j  &&
> cp -vfr doc/*     /usr/share/doc/openssl-1.0.2j
3、創建符號鏈接
[root@localhost openssl-1.0.2j]# ll/usr/lib64 | grep libssl.so.10
[root@localhost openssl-1.0.2j]# ll/usr/lib64 | grep libcrypto.so.10
[root@localhost openssl-1.0.2j]# ln -s/usr/src/openssl-1.0.2j/libssl.so.1.0.0 /usr/lib64/libssl.so.10
[root@localhost openssl-1.0.2j]# ln -s/usr/src/openssl-1.0.2j/libcrypto.so.1.0.0 /usr/lib64/libcrypto.so.10
[root@localhost openssl-1.0.2j]# ldconfig
4、驗證版本
[root@localhost openssl-1.0.2j]# opensslversion
OpenSSL 1.0.2j  26 Sep 2016

 

三、升級openssh,並刪除老版本

-參考:

http://www.linuxfromscratch.org/blfs/view/svn/postlfs/openssh.html

1、準備工作
[root@localhost openssh-7.3p1]# install  -v -m700 -d /var/lib/sshd &&
> chown    -v root:sys /var/lib/sshd &&
>
> groupadd -g 50 sshd        &&
> useradd  -c 'sshd PrivSep' \
>          -d /var/lib/sshd  \
>          -g sshd           \
>          -s /bin/false     \
>          -u 50 sshd
2、配置、編譯

-解包

[root@localhost src]# tar zxfopenssh-7.3p1.tar.gz
[root@localhost src]# cd openssh-7.3p1

-配置、編譯

[root@localhost openssh-7.3p1]# ./configure--prefix=/usr                     \
>             --sysconfdir=/etc/ssh             \
>             --with-md5-passwords              \
>             --with-privsep-path=/var/lib/sshd&&
> make

-卸載舊版本

[root@localhost openssh-7.3p1]# 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
[root@localhost openssh-7.3p1]# rpm -e `rpm-qa | grep openssh` --nodeps

-安裝

[root@localhost openssh-7.3p1]# makeinstall &&
> install -v -m755    contrib/ssh-copy-id /usr/bin     &&
>
> install -v -m644    contrib/ssh-copy-id.1 \
>                     /usr/share/man/man1              &&
> install -v -m755 -d/usr/share/doc/openssh-7.3p1     &&
> install -v -m644    INSTALL LICENCE OVERVIEW README* \
>                    /usr/share/doc/openssh-7.3p1

-驗證版本

[root@localhost openssh-7.3p1]# ssh -V
OpenSSH_7.3p1, OpenSSL 1.0.2j  26 Sep 2016

-添加啓動腳本

[root@localhost ~]# cp/usr/src/openssh-7.3p1/contrib/redhat/sshd.init /etc/init.d/sshd

-加入開機自啓

[root@localhost ~]# chkconfig --add sshd
[root@localhost ~]# chkconfig sshd on
[root@localhost ~]# chkconfig sshd --list
sshd             0:關閉     1:關閉     2:啓用     3:啓用     4:啓用     5:啓用     6:關閉

-啓動sshd

[root@localhost ~]# service sshd start
Starting sshd:                                             [確定]

 

四、驗證

-遠程退出重新登錄

[root@localhost ~]# exit
logout
[c:\~]$ ssh [email protected]



 

如出現root無法登錄

wKiom1hFTwjCmg03AAEhPcTFQoY098.jpg-wh_50

需要利用其它用戶登錄修改配置文件

[c:\~]$ ssh [email protected]
Connecting to 192.168.10.151:22...
Connection established.
To escape to local shell, press'Ctrl+Alt+]'.
 
[u1@localhost ~]$ su - root
密碼:
[root@localhost ~]#

 

 

-修改sshd_config

[root@localhost ~]# vim/etc/ssh/sshd_config
 
 
# Authentication:
 
 
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
 
[root@localhost ~]# service sshd restart
Stopping sshd:                                             [確定]
Starting sshd:                                             [確定]
[root@localhost ~]# exit
logout
[u1@localhost ~]$ exit
Logout

 

-再次驗證

[c:\~]$ ssh [email protected]
 
 
Connecting to 192.168.10.151:22...
Connection established.
To escape to local shell, press'Ctrl+Alt+]'.
 
Last login: Sun Sep 25 20:07:17 2016 from192.168.10.1
[root@localhost ~]# openssl version
OpenSSL 1.0.2j  26 Sep 2016
[root@localhost ~]# ssh -V
OpenSSH_7.3p1, OpenSSL 1.0.2j  26 Sep 2016


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章