How to install openssh from source code in centos 7

How to install openssh from source code in centos 7

Environment: CentOS 7.1.1503 Minimum Installation

Download dependency packages: yum -y install lrzsz zlib-devel perl gcc pam-devel

1. Install openssl and choose the latest released 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 system pre-installed openssl, 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 the version

openssl version

2. Install openssh, choose the latest released 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 system's openssh configuration file

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 system pre-installed openssh, 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 backed-up 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 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 at 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 worried, you can reboot the machine

ps: Let's see how to solve the problem of not generating dynamic link library .so when compiling and installing openssl under Linux

The config command provided by the official website does not generate .so 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

Summarize

This is the end of this article about how to install openssh from centos 7 source code. For more information about how to install openssh from centos 7 source code, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • CentOS method to modify the default ssh port number example
  • How to add or modify SSH port number in CentOS7
  • How to modify the SSH login port in CentOS7
  • Install and configure ssh in CentOS7

<<:  Detailed explanation of mandatory and implicit conversion of types in JavaScript

>>:  When Navicat connects to MySQL, it reports 10060, 1045 errors and the location of my.ini

Recommend

The principle and application of ES6 deconstruction assignment

Table of contents Array destructuring assignment ...

Docker binding fixed IP/cross-host container mutual access operation

Preface Previously, static IPs assigned using pip...

Implementation of mysql8.0.11 data directory migration

The default storage directory of mysql is /var/li...

Five things a good user experience designer should do well (picture and text)

This article is translated from the blog Usability...

Chrome plugin (extension) development guide (complete demo)

Table of contents Written in front Preface What i...

Detailed explanation of Vue lazyload picture lazy loading example

Documentation: https://github.com/hilongjw/vue-la...

Detailed process of drawing three-dimensional arrow lines using three.js

Demand: This demand is an urgent need! In a subwa...

A brief discussion on two methods to solve space-evenly compatibility issues

Since its launch in 2009, flex has been supported...

The implementation of Youda's new petite-vue

Table of contents Preface Introduction Live Easy ...

MySQL 8.0.19 installation and configuration method graphic tutorial

This article records the installation and configu...

Summary of some practical little magic in Vue practice

How can you forget lazy loading of routes that al...

jQuery implements simple pop-up window effect

This article shares the specific code of jQuery t...

HTML table markup tutorial (1): Creating a table

<br />This is a series of tutorials provided...