Environment: centos 7.1.1503 minimal installation
Dependent package download: yum -y install lrzsz zlib-devel perl gcc pam-devel
1、 Install openssl, choose the latest version: openssl-1.1.1g.tar.gz
1 ) Openssl download address: https://www.openssl.org/source/openssl-1.1.1g.tar.gz
2 ) Uninstall the openssl pre-installed in the system, this step can be omitted
rpm -qa | grep openssl | grep -v lib
yum -y remove openssl-1.0.1e-42.el7.x86_64
3 )installation steps:
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 ) Create a soft link
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
5 ) Update system configuration
echo “/usr/local/openssl/lib” >> /etc/ld.so.conf
/sbin/ldconfig
6 ) Check version
openssl version
2、 Install openssh, choose the latest version: openssh-8.3p1.tar.gz
1 ) Openssh download address: https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.3p1.tar.gz
2 ) Back up the openssh configuration file of the system
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/[email protected] /usr/lib/systemd/system/[email protected]
cp -r /usr/lib/systemd/system/sshd-keygen.service /usr/lib/systemd/system/sshd-keygen.service.bak
3 ) Uninstall the openssh pre-installed in the system, this step can be omitted
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 ) Back up the openssh configuration file, this step can be omitted
cp -r /etc/ssh /etc/ssh.bak
rm -rf /etc/ssh #This step is very important and must be done
5 )installation steps
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 ) Create a soft link
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 ) Restore the backup configuration file
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/[email protected] /usr/lib/systemd/system/[email protected]
mv /usr/lib/systemd/system/sshd-keygen.service.bak /usr/lib/systemd/system/sshd-keygen.service
8 ) Check the openssh version
ssh -V
9 ) Modify the openssh configuration file to allow root login
vi /etc/ssh/sshd_config
Change #PermitRootLogin prohibit-password to PermitRootLogin yes
10 ) Set the sshd service to start on boot
chkconfig sshd on
11 ) Restart the sshd service
systemctl restart sshd && systemctl restart sshd && systemctl restart sshd && systemctl restart sshd &
At this point, the openssh service installation is complete, if you are not assured, you can reboot to restart the machine
ps: Let’s see how to solve the problem of compiling and installing openssl under Linux without generating dynamic link library .so
Using the official config command, the .so is not generated by default. The solution is to add the parameter shared when executing ./config, for example:
. /config –prefix=/usr/local/ssl –openssldir=/usr/local/ssl -Wl,-rpath,/usr/local/ssl/lib shared
Then make && make install
Recommended Posts