centos 7 源碼安裝openssh的方法
環(huán)境:centos 7.1.1503 最小化安裝
依賴包下載: yum -y install lrzsz zlib-devel perl gcc pam-devel
1、安裝openssl ,選用最新發(fā)布的版本:openssl-1.1.1g.tar.gz
1)openssl下載地址:https://www.openssl.org/source/openssl-1.1.1g.tar.gz
2)卸載系統(tǒng)預裝的openssl ,這一步可以不做
rpm -qa | grep openssl | grep -v lib
yum -y remove openssl-1.0.1e-42.el7.x86_64
3)安裝步驟:
tar -zxvfopenssl-1.1.1g.tar.gz
cdcd openssl-1.1.1g
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl -Wl,-rpath,/usr/local/openssl/lib shared
make && make install
4)創(chuàng)建軟鏈接
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
5)更新系統(tǒng)配置
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
/sbin/ldconfig
6)檢查版本
openssl version
2、安裝openssh,選用最新發(fā)布的版本:openssh-8.3p1.tar.gz
1)openssh下載地址:https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.3p1.tar.gz
2)備份系統(tǒng)的openssh配置文件
cp -r /etc/sysconfig/sshd /etc/sysconfig/sshd.bak
cp -r /sys/fs/cgroup/systemd/system.slice/sshd.service /sys/fs/cgroup/systemd/system.slice/sshd.service.bak
cp -r /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/sshd.service.bak
cp -r /usr/lib/systemd/system/sshd.socket /usr/lib/systemd/system/sshd.socket.bak
cp -r /usr/lib/systemd/system/sshd@.service /usr/lib/systemd/system/sshd@.service.bak
cp -r /usr/lib/systemd/system/sshd-keygen.service /usr/lib/systemd/system/sshd-keygen.service.bak
3)卸載系統(tǒng)預裝的openssh,這一步可以不做
rpm -qa | grep openssh
yum -y remove openssh-server-6.6.1p1-11.el7.x86_64 openssh-clients-6.6.1p1-11.el7.x86_64 openssh-6.6.1p1-11.el7.x86_64
4)備份openssh配置文件,這一步可以不做
cp -r /etc/ssh /etc/ssh.bak
rm -rf /etc/ssh #這一步很重要,必須做
5)安裝步驟
tar -zxvf openssh-8.3p1.tar.gz
cd openssh-8.3p1
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/openssl/include --with-ssl-dir=/usr/local/openssl --with-zlib --with-md5-passwords --with-pam --with-ssl-engine
make && make install
6)創(chuàng)建軟鏈接
ln -s /usr/local/openssh/sbin/sshd /sbin/sshd
ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh
ln -s /usr/local/openssh/bin/ssh-add /usr/bin/ssh-add
ln -s /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
ln -s /usr/local/openssh/bin/ssh-keyscan /usr/bin/ssh-keyscan
7)恢復備份的配置文件
mv /etc/sysconfig/sshd.bak /etc/sysconfig/sshd
mv /sys/fs/cgroup/systemd/system.slice/sshd.service.bak /sys/fs/cgroup/systemd/system.slice/sshd.service
mv /usr/lib/systemd/system/sshd.service.bak /usr/lib/systemd/system/sshd.service
mv /usr/lib/systemd/system/sshd.socket.bak /usr/lib/systemd/system/sshd.socket
mv /usr/lib/systemd/system/sshd@.service.bak /usr/lib/systemd/system/sshd@.service
mv /usr/lib/systemd/system/sshd-keygen.service.bak /usr/lib/systemd/system/sshd-keygen.service
8)檢查openssh版本
ssh -V
9)修改openssh的配置文件,允許root登錄
vi /etc/ssh/sshd_config
將 #PermitRootLogin prohibit-password 修改為PermitRootLogin yes
10)將sshd服務設為開機啟動
chkconfig sshd on
11)重啟sshd服務
systemctl restart sshd && systemctl restart sshd && systemctl restart sshd && systemctl restart sshd &
至此openssh服務安裝完成,不放心的話可以reboot重啟機器
ps:下面看下Linux下編譯安裝openssl不生成動態(tài)鏈接庫.so的問題解決
使用官方提供的config命令默認竟然沒有生成 .so,解決辦法執(zhí)行 ./config 時增加參數(shù) shared,例如:
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl -Wl,-rpath,/usr/local/ssl/lib shared
然后 make && make install 即可
總結
到此這篇關于centos 7 源碼安裝openssh的方法的文章就介紹到這了,更多相關centos 7 源碼安裝openssh內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
centos7修改系統(tǒng)語言為簡體中文的實現(xiàn)
這篇文章主要介紹了centos7修改系統(tǒng)語言為簡體中文的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-04-04解決Linux系統(tǒng)yum安裝報錯Cannot find a valid base
本文介紹了如何在Linux系統(tǒng)中設置本地yum源,包括修改yum配置文件、禁用默認網(wǎng)絡源、創(chuàng)建掛載點以及掛載鏡像文件等步驟,操作詳細,適合需要離線安裝軟件或更新系統(tǒng)的用戶參考2024-09-09centos6.5 lamp 環(huán)境(使用yum安裝方法)
這篇文章主要介紹了centos6.5下安裝lamp環(huán)境 使用yum安裝方法,需要的朋友可以參考下2016-10-10Centos7.2 系統(tǒng)上yum安裝lamp環(huán)境
這篇文章主要介紹了centos7.2 系統(tǒng)上yum安裝lamp環(huán)境的相關資料,非常不錯具有參考借鑒價值,需要的朋友可以參考下2016-11-11linux實現(xiàn)對上傳文件的定時備份、增量備份的方法
這篇文章主要介紹了linux實現(xiàn)對上傳文件的定時備份、增量備份的方法,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-04-04Centos8最小化部署安裝OpenStack Ussuri的詳細教程
這篇文章主要介紹了Centos8最小化部署安裝OpenStack Ussuri的詳細教程,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-08-08