How to install openssh from centos 7 source code

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

How to install openssh from centos 7 source code
How to install Visual Studio Code on CentOS 8
Install MySQL 8.x from source code under CentOS7
How to compile and install xdebug from source code in Ubuntu environment
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
How to install Memcached on CentOS 8
How to install R on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install PHP7.4 in CentOS
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
How to install Ruby on CentOS 8
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Python on CentOS 8
How to install Elasticsearch on CentOS 8
How to install HDP2.6 in Centos7.2
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
How to install htop on CentOS 8
How to install TeamViewer on CentOS 8
How to install MariaDB on CentOS 8
How to install MongoDB on CentOS 7
How to install Odoo 13 on CentOS 8
How to install Apache on CentOS 8
How to install OpenCV on CentOS 8
How to install PHP on CentOS 8
How to install MongoDB on CentOS 8
How to install Android SDK in centos7
CentOS7.5 source code compile and install mysql5.7.29
How to install Apache Maven on CentOS 8
How to install Apache Kafka on CentOS 7
[Graphic] How to install tomcat on centos
R&D: How To Install Python 3 on CentOS 7
How to install GCC compiler on CentOS 7
CentOS7.4 source code compile and install MySQL8.0
How to install offline JDK1.8 on centos7.0
How to install Visual Studio Code on Ubuntu 20.04
How to install and configure Elasticsearch on CentOS 7
How to install and use Docker on CentOS 7
How to install RPM packages on CentOS Linux
How to install and configure VNC on CentOS 8
How to install and use Composer on CentOS 8
How to install and configure Redis on CentOS 8