服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Centos - centos 7 源码安装openssh的方法

centos 7 源码安装openssh的方法

2020-07-20 20:40tianyingz Centos

这篇文章主要介绍了centos 7 源码安装openssh的方法,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

环境:centos 7.1.1503 最小化安装

依赖包下载: yum -y install lrzsz zlib-devel perl gcc pam-devel

1、安装openssl ,选用最新发布的版本:openssl-1.1.1g.tar.gz

1)openssl下载地址:https://www.openssl.org/source/openssl-1.1.1g.tar.gz

2)卸载系统预装的openssl ,这一步可以不做

rpm -qa | grep openssl | grep -v lib

yum -y remove openssl-1.0.1e-42.el7.x86_64

centos 7 源码安装openssh的方法

3)安装步骤:

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)创建软链接

ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

ln -s /usr/local/openssl/include/openssl /usr/include/openssl

5)更新系统配置

echo "/usr/local/openssl/lib" >> /etc/ld.so.conf

/sbin/ldconfig

6)检查版本

openssl version

centos 7 源码安装openssh的方法

2、安装openssh,选用最新发布的版本:openssh-8.3p1.tar.gz

1)openssh下载地址:https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.3p1.tar.gz

2)备份系统的openssh配置文件

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/sshd@.service /usr/lib/systemd/system/sshd@.service.bak

cp -r /usr/lib/systemd/system/sshd-keygen.service /usr/lib/systemd/system/sshd-keygen.service.bak

3)卸载系统预装的openssh,这一步可以不做

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

centos 7 源码安装openssh的方法

4)备份openssh配置文件,这一步可以不做

cp -r /etc/ssh /etc/ssh.bak

rm -rf /etc/ssh  #这一步很重要,必须做

5)安装步骤

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)创建软链接

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)恢复备份的配置文件

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/sshd@.service.bak /usr/lib/systemd/system/sshd@.service

mv /usr/lib/systemd/system/sshd-keygen.service.bak /usr/lib/systemd/system/sshd-keygen.service

8)检查openssh版本

ssh -V

centos 7 源码安装openssh的方法

9)修改openssh的配置文件,允许root登录

vi /etc/ssh/sshd_config

将 #PermitRootLogin prohibit-password 修改为PermitRootLogin yes

centos 7 源码安装openssh的方法

10)将sshd服务设为开机启动

chkconfig sshd on

11)重启sshd服务

systemctl restart sshd && systemctl restart sshd && systemctl restart sshd && systemctl restart sshd &

centos 7 源码安装openssh的方法

至此openssh服务安装完成,不放心的话可以reboot重启机器

ps:下面看下Linux下编译安装openssl不生成动态链接库.so的问题解决

使用官方提供的config命令默认竟然没有生成 .so,解决办法执行 ./config 时增加参数 shared,例如:

./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl -Wl,-rpath,/usr/local/ssl/lib shared

然后 make && make install 即可

总结

到此这篇关于centos 7 源码安装openssh的方法的文章就介绍到这了,更多相关centos 7 源码安装openssh内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://www.cnblogs.com/tianyingz/p/13048442.html

延伸 · 阅读

精彩推荐
  • CentosCentOS6.2网卡设置

    CentOS6.2网卡设置

    如果你想让服务器可以更新、让网友访问你的LINUX服务器,那一定要设置LINUX网上给网卡绑定一个IP,下面我们就介绍CentOS6.2网卡设置IP的方法。...

    CentOS教程网10092021-10-03
  • Centos使用Xshell连接Centos 6.6服务器操作图文教程

    使用Xshell连接Centos 6.6服务器操作图文教程

    这篇文章主要介绍了使用Xshell连接Centos 6.6服务器操作图文教程,本文用详细的操作步骤讲解了如何使用Xshell连接Centos服务器,需要的朋友可以参考下 ...

    脚本之家4032019-09-18
  • Centoscentos 7中添加一个新用户并授权的步骤详解

    centos 7中添加一个新用户并授权的步骤详解

    这篇文章主要给大家介绍了关于在centos 7中添加一个新用户并授权的步骤,文中将实现的步骤介绍的非常详细,通过文中介绍的步骤可以轻松的创建一个新...

    Ryan.Miao9832022-02-12
  • CentosCentOS7 阿里云的yum源使用详解

    CentOS7 阿里云的yum源使用详解

    这篇文章主要介绍了CentOS7 阿里云的yum源使用详解的相关资料,这里对备份yum源,添加EPEL源,和缓存清理,进行了介绍,需要的朋友可以参考下...

    天王9312020-12-28
  • CentosCentOS上SVN服务器端程序的安装与使用教程

    CentOS上SVN服务器端程序的安装与使用教程

    SVN是一款高人气的软件项目版本控制系统,由于其在Windows的客户端的简易操作,在Git的浪潮中仍然保有很多的用户数量,这里我们就来看一下CentOS上SVN服务器端...

    cnblogs3902019-07-16
  • CentosCentOS 最新版本git的安装教程

    CentOS 最新版本git的安装教程

    本文主要给大家介绍了CentOS 最新版本git的安装教程,非常不错,具有参考借鉴价值,感兴趣的朋友一起看看吧...

    CentOS教程网9252021-11-29
  • CentosCentOS系统下软件包的制作方法和过程详解

    CentOS系统下软件包的制作方法和过程详解

    今天小编将为大家带来的是CentOS系统下软件包的制作方法和过程详解;希望对大家会有帮助,有需要的朋友一起去看看吧...

    CentOS之家4802019-05-30
  • Centos在CentOS系统上安装Docker的教程

    在CentOS系统上安装Docker的教程

    这篇文章主要介绍了在CentOS系统上安装Docker的教程,Docker是当下人气最为火热的容器类虚拟软件,需要的朋友可以参考下 ...

    开源中文社区3952019-09-17