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

Solution to Navicat Premier remote connection to MySQL error 10038

Remote connection to MySQL fails, there may be th...

Summary of Common Letters in Unicode

Most of the earliest computers could only use ASC...

js to implement verification code interference (static)

This article shares the specific code of js to im...

Mysql date formatting and complex date range query

Table of contents Preface Query usage scenario ca...

Conditional comment style writing method and sample code

As front-end engineers, IE must be familiar to us...

5 common scenarios and examples of JavaScript destructuring assignment

Table of contents Preface 1. Extract data 2. Alia...

MySQL kill command usage guide

KILL [CONNECTION | QUERY] processlist_id In MySQL...

Detailed tutorial on using cmake to compile and install mysql under linux

1. Install cmake 1. Unzip the cmake compressed pa...

Summary of common tool examples in MySQL (recommended)

Preface This article mainly introduces the releva...

MySQL 8.0.18 Installation Configuration Optimization Tutorial

Mysql installation, configuration, and optimizati...

How to use Javascript to generate smooth curves

Table of contents Preface Introduction to Bezier ...

JavaScript to implement input box content prompt and hidden function

Sometimes the input box is small, and you want to...