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

Share the pitfalls of MySQL's current_timestamp and their solutions

Table of contents MySQL's current_timestamp p...

Native js to implement a simple calculator

This article example shares the specific code of ...

Example of implementing load balancing with Nginx+SpringBoot

Introduction to Load Balancing Before introducing...

10 skills that make front-end developers worth millions

The skills that front-end developers need to mast...

mysql create database, add users, user authorization practical method

1. Create a MySQL database 1. Create database syn...

Vue implements div wheel zooming in and out

Implement div wheel zooming in and out in Vue pro...

What are the attributes of the JSscript tag

What are the attributes of the JS script tag: cha...

How to remove the dotted border when clicking a link in FireFox

I encountered several browser compatibility issue...

Tutorial on setting up scheduled tasks to backup the Oracle database under Linux

1. Check the character set of the database The ch...

5 tips for writing CSS to make your style more standardized

1. Arrange CSS in alphabetical order Not in alphab...

How to change the encoding of MySQL database to utf8mb4

The utf8mb4 encoding is a superset of the utf8 en...

Linux kernel device driver kernel time management notes

/****************** * Linux kernel time managemen...