一、参考链接??

OpenSSH

阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区 (aliyun.com)

openssh镜像-openssh下载地址-openssh安装教程-阿里巴巴开源镜像站 (aliyun.com)

OpenSSH8.6安装教程_wqww_1的博客-CSDN博客_openssh8.6安装包

二、OpenSSH简介?

OpenSSH(OpenBSD Secure Shell)是使用SSH透过计算机网络加密通信的实现。它是取代由SSH Communications Security所提供的商用版本的开放源代码方案。目前OpenSSH是OpenBSD的子项目。

OpenSSH常常被误认以为与OpenSSL有关系,但实际上这两个项目有不同的目的,不同的发展团队,名称相近只是因为两者有同样的软件发展目标──提供开放源代码的加密通信软件。

来源:维基百科

三、OpenSSH安装操作?

1、清除缓存并更新YUM源?

  1. [root@centos ~]# yum clean all
  2. Loaded plugins: fastestmirror
  3. Cleaning repos: base extras updates
  4. Cleaning up list of fastest mirrors
  5. [root@centos ~]# yum repolist
  6. Loaded plugins: fastestmirror
  7. Loading mirror speeds from cached hostfile
  8. * base: mirrors.aliyun.com
  9. * extras: mirrors.aliyun.com
  10. * updates: mirrors.aliyun.com
  11. repo id repo name status
  12. base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
  13. extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 500
  14. updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 3,190
  15. repolist: 13,762

2、查看原来SSH版本信息并卸载?

  1. [root@centos ~]# rpm -qa | grep ssh
  2. openssh-clients-7.4p1-21.el7.x86_64
  3. openssh-7.4p1-21.el7.x86_64
  4. openssh-server-7.4p1-21.el7.x86_64
  5. libssh2-1.8.0-4.el7.x86_64
  6. [root@centos ~]# ssh -V
  7. OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
  8. [root@centos ~]# rpm -qa | grep openssh | xargs rpm -e --nodeps
  9. [root@centos ~]# rpm -qa | grep openssh
  10. [root@centos ~]#

3、本地下载OpenSSH镜像包并上传至Linux系统?

(或者采用步骤4,二者取其一即可)

下载链接:阿里云开源镜像站资源目录 (aliyun.com)

image-20211214124129534

image-20211214124003962

4、使用wget命令下载OpenSSH安装包?

复制链接地址。

https://mirrors.aliyun.com/openssh/portable/openssh-8.8p1.tar.gz

image-20211214124322822

使用wget命令下载。?

  1. [root@centos ~]# wget https://mirrors.aliyun.com/openssh/portable/openssh-8.8p1.tar.gz
  2. --2021-12-15 12:43:53-- https://mirrors.aliyun.com/openssh/portable/openssh-8.8p1.tar.gz
  3. Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 27.221.120.242, 61.162.46.209, 27.221.120.240, ...
  4. Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|27.221.120.242|:443... connected.
  5. HTTP request sent, awaiting response... 200 OK
  6. Length: 1815060 (1.7M) [application/octet-stream]
  7. Saving to: openssh-8.8p1.tar.gz
  8. 100%[==============================================================================>] 1,815,060 3.36MB/s in 0.5s
  9. 2021-12-15 12:43:54 (3.36 MB/s) - openssh-8.8p1.tar.gz saved [1815060/1815060]
  10. [root@centos ~]#

5、采用源码进行安装?

  1. #查看openssh安装包
  2. [root@centos ~]# ll
  3. total 1780
  4. -rw-------. 1 root root 1531 Nov 28 17:50 anaconda-ks.cfg
  5. -rw-r--r-- 1 root root 1815060 Sep 26 22:39 openssh-8.8p1.tar.gz
  6. [root@centos ~]#
  7. [root@centos ~]# tar -zxvf openssh-8.8p1.tar.gz
  8. [root@centos ~]# ll
  9. total 1796
  10. -rw-------. 1 root root 1531 Nov 28 17:50 anaconda-ks.cfg
  11. drwxr-xr-x 7 1000 1000 12288 Sep 26 22:07 openssh-8.8p1
  12. -rw-r--r-- 1 root root 1815060 Sep 26 22:39 openssh-8.8p1.tar.gz
  13. #安装依赖包
  14. [root@centos ~]# cd openssh-8.8p1
  15. [root@centos openssh-8.8p1]# ls
  16. ······省略
  17. [root@centos openssh-8.8p1]# yum install -y lrzsz zlib-devel perl gcc pam-devel openssl-devel
  18. ··········
  19. 安装过程省略
  20. ··········
  21. Installed:
  22. gcc.x86_64 0:4.8.5-44.el7 lrzsz.x86_64 0:0.12.20-36.el7 openssl-devel.x86_64 1:1.0.2k-22.el7_9
  23. pam-devel.x86_64 0:1.1.8-23.el7 perl.x86_64 4:5.16.3-299.el7_9 zlib-devel.x86_64 0:1.2.7-19.el7_9
  24. Dependency Installed:
  25. keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-51.el7_9
  26. libcom_err-devel.x86_64 0:1.42.9-19.el7 libkadm5.x86_64 0:1.15.1-51.el7_9
  27. libselinux-devel.x86_64 0:2.5-15.el7 libsepol-devel.x86_64 0:2.5-10.el7
  28. libverto-devel.x86_64 0:0.2.5-4.el7 pcre-devel.x86_64 0:8.32-17.el7
  29. perl-Carp.noarch 0:1.26-244.el7 perl-Encode.x86_64 0:2.51-7.el7
  30. perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7
  31. perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7
  32. perl-Getopt-Long.noarch 0:2.40-3.el7 perl-HTTP-Tiny.noarch 0:0.033-3.el7
  33. perl-PathTools.x86_64 0:3.40-5.el7 perl-Pod-Escapes.noarch 1:1.04-299.el7_9
  34. perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7
  35. perl-Pod-Usage.noarch 0:1.63-3.el7 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7
  36. perl-Socket.x86_64 0:2.010-5.el7 perl-Storable.x86_64 0:2.45-3.el7
  37. perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7
  38. perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7
  39. perl-libs.x86_64 4:5.16.3-299.el7_9 perl-macros.x86_64 4:5.16.3-299.el7_9
  40. perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7
  41. perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7
  42. Dependency Updated:
  43. krb5-libs.x86_64 0:1.15.1-51.el7_9 openssl.x86_64 1:1.0.2k-22.el7_9 openssl-libs.x86_64 1:1.0.2k-22.el7_9
  44. Complete!
  45. [root@centos openssh-8.8p1]#
  46. # 安装OpenSSH
  47. [root@centos openssh-8.8p1]# ./configure --prefix=/usr/local/ssh --sysconfdir=/etc/ssh --with-pam
  48. OpenSSH has been configured with the following options:
  49. User binaries: /usr/local/ssh/bin
  50. System binaries: /usr/local/ssh/sbin
  51. Configuration files: /etc/ssh
  52. Askpass program: /usr/local/ssh/libexec/ssh-askpass
  53. Manual pages: /usr/local/ssh/share/man/manX
  54. PID file: /var/run
  55. Privilege separation chroot path: /var/empty
  56. sshd default user PATH: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/ssh/bin
  57. Manpage format: doc
  58. PAM support: yes
  59. OSF SIA support: no
  60. KerberosV support: no
  61. SELinux support: no
  62. MD5 password support: no
  63. libedit support: no
  64. libldns support: no
  65. Solaris process contract support: no
  66. Solaris project support: no
  67. Solaris privilege support: no
  68. IP address in $DISPLAY hack: no
  69. Translate v4 in v6 hack: yes
  70. BSD Auth support: no
  71. Random number source: OpenSSL internal ONLY
  72. Privsep sandbox style: seccomp_filter
  73. PKCS#11 support: yes
  74. U2F/FIDO support: yes
  75. Host: x86_64-pc-linux-gnu
  76. Compiler: cc
  77. Compiler flags: -g -O2 -pipe -Wall -Wextra -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-parameter -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -fstack-protector-strong -fPIE
  78. Preprocessor flags: -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE
  79. Linker flags: -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -fstack-protector-strong -pie
  80. Libraries: -lcrypto -ldl -lutil -lz -lcrypt -lresolv
  81. +for sshd: -lpam
  82. PAM is enabled. You may need to install a PAM control file
  83. for sshd, otherwise password authentication may fail.
  84. Example PAM control files can be found in the contrib/
  85. subdirectory
  86. [root@centos openssh-8.8p1]#
  87. # 开始编译安装
  88. [root@centos openssh-8.8p1]# make
  89. ······
  90. 编译过程省略
  91. ······
  92. [root@centos openssh-8.8p1]# make install
  93. (cd openbsd-compat && make)
  94. make[1]: Entering directory `/root/openssh-8.8p1/openbsd-compat'
  95. make[1]: Nothing to be done for `all'.
  96. make[1]: Leaving directory `/root/openssh-8.8p1/openbsd-compat'
  97. /usr/bin/mkdir -p /usr/local/ssh/bin
  98. /usr/bin/mkdir -p /usr/local/ssh/sbin
  99. /usr/bin/mkdir -p /usr/local/ssh/share/man/man1
  100. /usr/bin/mkdir -p /usr/local/ssh/share/man/man5
  101. /usr/bin/mkdir -p /usr/local/ssh/share/man/man8
  102. /usr/bin/mkdir -p /usr/local/ssh/libexec
  103. /usr/bin/mkdir -p -m 0755 /var/empty
  104. /usr/bin/install -c -m 0755 -s ssh /usr/local/ssh/bin/ssh
  105. /usr/bin/install -c -m 0755 -s scp /usr/local/ssh/bin/scp
  106. /usr/bin/install -c -m 0755 -s ssh-add /usr/local/ssh/bin/ssh-add
  107. /usr/bin/install -c -m 0755 -s ssh-agent /usr/local/ssh/bin/ssh-agent
  108. /usr/bin/install -c -m 0755 -s ssh-keygen /usr/local/ssh/bin/ssh-keygen
  109. /usr/bin/install -c -m 0755 -s ssh-keyscan /usr/local/ssh/bin/ssh-keyscan
  110. /usr/bin/install -c -m 0755 -s sshd /usr/local/ssh/sbin/sshd
  111. /usr/bin/install -c -m 4711 -s ssh-keysign /usr/local/ssh/libexec/ssh-keysign
  112. /usr/bin/install -c -m 0755 -s ssh-pkcs11-helper /usr/local/ssh/libexec/ssh-pkcs11-helper
  113. /usr/bin/install -c -m 0755 -s ssh-sk-helper /usr/local/ssh/libexec/ssh-sk-helper
  114. /usr/bin/install -c -m 0755 -s sftp /usr/local/ssh/bin/sftp
  115. /usr/bin/install -c -m 0755 -s sftp-server /usr/local/ssh/libexec/sftp-server
  116. /usr/bin/install -c -m 644 ssh.1.out /usr/local/ssh/share/man/man1/ssh.1
  117. /usr/bin/install -c -m 644 scp.1.out /usr/local/ssh/share/man/man1/scp.1
  118. /usr/bin/install -c -m 644 ssh-add.1.out /usr/local/ssh/share/man/man1/ssh-add.1
  119. /usr/bin/install -c -m 644 ssh-agent.1.out /usr/local/ssh/share/man/man1/ssh-agent.1
  120. /usr/bin/install -c -m 644 ssh-keygen.1.out /usr/local/ssh/share/man/man1/ssh-keygen.1
  121. /usr/bin/install -c -m 644 ssh-keyscan.1.out /usr/local/ssh/share/man/man1/ssh-keyscan.1
  122. /usr/bin/install -c -m 644 moduli.5.out /usr/local/ssh/share/man/man5/moduli.5
  123. /usr/bin/install -c -m 644 sshd_config.5.out /usr/local/ssh/share/man/man5/sshd_config.5
  124. /usr/bin/install -c -m 644 ssh_config.5.out /usr/local/ssh/share/man/man5/ssh_config.5
  125. /usr/bin/install -c -m 644 sshd.8.out /usr/local/ssh/share/man/man8/sshd.8
  126. /usr/bin/install -c -m 644 sftp.1.out /usr/local/ssh/share/man/man1/sftp.1
  127. /usr/bin/install -c -m 644 sftp-server.8.out /usr/local/ssh/share/man/man8/sftp-server.8
  128. /usr/bin/install -c -m 644 ssh-keysign.8.out /usr/local/ssh/share/man/man8/ssh-keysign.8
  129. /usr/bin/install -c -m 644 ssh-pkcs11-helper.8.out /usr/local/ssh/share/man/man8/ssh-pkcs11-helper.8
  130. /usr/bin/install -c -m 644 ssh-sk-helper.8.out /usr/local/ssh/share/man/man8/ssh-sk-helper.8
  131. /usr/bin/mkdir -p /etc/ssh
  132. ssh-keygen: generating new host keys: DSA
  133. /usr/local/ssh/sbin/sshd -t -f /etc/ssh/sshd_config
  134. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  135. @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
  136. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  137. Permissions 0640 for '/etc/ssh/ssh_host_rsa_key' are too open.
  138. It is required that your private key files are NOT accessible by others.
  139. This private key will be ignored.
  140. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  141. @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
  142. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  143. Permissions 0640 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
  144. It is required that your private key files are NOT accessible by others.
  145. This private key will be ignored.
  146. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  147. @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
  148. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  149. Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' are too open.
  150. It is required that your private key files are NOT accessible by others.
  151. This private key will be ignored.
  152. sshd: no hostkeys available -- exiting.
  153. make: [check-config] Error 1 (ignored)
  154. [root@centos openssh-8.8p1]#

解压openssh-8.8p1.tar.gz压缩包,结果如下图所示。?

image-20211214125711172

通过YUM源命令安装lrzsz zlib-devel perl gcc pam-devel等服务组件,结果如下图所示了。??

image-20211214130657870

运行./configure —prefix=/usr/local/ssh —sysconfdir=/etc/ssh —with-pam此命令后,结果如下图所示。

image-20211214130940082

运行完make命令后,结果如下图所示。

image-20211214131219107

运行完make install命令后,结果如下图所示。

image-20211214131502219

6、修改相关参数?

  1. [root@centos openssh-8.8p1]# cd /etc/init.d/
  2. [root@centos init.d]# cp /root/openssh-8.8p1/contrib/redhat/sshd.init /etc/init.d/sshd
  3. [root@centos init.d]# ll
  4. total 44
  5. -rw-r--r--. 1 root root 18281 May 22 2020 functions
  6. -rwxr-xr-x. 1 root root 4569 May 22 2020 netconsole
  7. -rwxr-xr-x. 1 root root 7928 May 22 2020 network
  8. -rw-r--r--. 1 root root 1160 Oct 2 2020 README
  9. -rwxr-xr-x 1 root root 1721 Dec 15 13:20 sshd
  10. [root@centos init.d]# chmod u+x /etc/init.d/sshd
  11. [root@centos init.d]# chkconfig --add sshd
  12. [root@centos init.d]# cp /root/openssh-8.8p1/sshd_config /etc/ssh/ssh_config
  13. cp: overwrite ‘/etc/ssh/ssh_config’? y
  14. [root@centos init.d]# cp -r /usr/local/ssh/bin/* /usr/bin/
  15. [root@centos init.d]# cp -r /usr/local/ssh/sbin/* /usr/sbin/
  16. [root@centos init.d]# vi /etc/ssh/sshd_config
  17. 添加如下内容
  18. #PasswordAuthentication yes
  19. PermitRootLogin yes
  20. [root@centos init.d]#chmod 600 /etc/ssh/*

7、启动并查看SSH服务??

  1. [root@centos ~]# systemctl start sshd
  2. [root@centos ~]# systemctl restart sshd
  3. [root@centos ~]# systemctl status sshd
  4. sshd.service - SYSV: OpenSSH server daemon
  5. Loaded: loaded (/etc/rc.d/init.d/sshd; bad; vendor preset: enabled)
  6. Active: active (running) since Wed 2021-12-15 13:24:56 CST; 5s ago
  7. Docs: man:systemd-sysv-generator(8)
  8. Process: 19403 ExecStop=/etc/rc.d/init.d/sshd stop (code=exited, status=0/SUCCESS)
  9. Process: 19409 ExecStart=/etc/rc.d/init.d/sshd start (code=exited, status=0/SUCCESS)
  10. Main PID: 19417 (sshd)
  11. CGroup: /system.slice/sshd.service
  12. └─19417 sshd: /usr/sbin/sshd [listener] 0 of 10-100 startups
  13. Dec 15 13:24:56 centos systemd[1]: Stopped SYSV: OpenSSH server daemon.
  14. Dec 15 13:24:56 centos systemd[1]: Starting SYSV: OpenSSH server daemon...
  15. Dec 15 13:24:56 centos sshd[19409]: Starting sshd:[ OK ]
  16. Dec 15 13:24:56 centos systemd[1]: Can't open PID file /var/run/sshd.pid (yet?) after start: No such file or directory
  17. Dec 15 13:24:56 centos sshd[19417]: Server listening on 0.0.0.0 port 22.
  18. Dec 15 13:24:56 centos sshd[19417]: Server listening on :: port 22.
  19. Dec 15 13:24:56 centos systemd[1]: Started SYSV: OpenSSH server daemon.

8、查看SSH服务版本信息。??

  1. [root@centos ~]# ssh -V
  2. OpenSSH_8.8p1, OpenSSL 1.0.2k-fips 26 Jan 2017

image-20211214132831394

更多相关文章

  1. Android中检测App是否安装的方法.
  2. 多个Android(安卓)device offline处理命令
  3. mysql 8.0.18 压缩包安装及忘记密码重置所遇到的坑
  4. mysql8.0忘记密码修改与net命令服务名无效问题
  5. Win10 64位使用压缩包安装最新MySQL8.0.18的教程(图文详解)
  6. 解决Win10系统安装MySQL8.0遇到的问题
  7. MySql Installer 8.0.18可视化安装教程图文详解
  8. Linux下安装MySQL8.0.11的教程
  9. mysql 8.0.18各版本安装及安装中出现的问题(精华总结)

随机推荐

  1. 使用 Netty 实现 IM 聊天贼简单,看不懂就
  2. 帅气的 Spring Session 功能,基于 Redis
  3. kubernets 挂载 NAS 报 access denied
  4. Apollo 源码解析 —— Portal 认证与授权
  5. Linux学习:文件IO(不带缓冲区),原子操作概念
  6. Linux学习:unix的标准化的实现(Linux中各种
  7. 艿艿的 Spring Cloud Alibaba!开整~
  8. 37000 字 + 代码,艿艿肝的 Shiro 从入门到
  9. Linux学习:Linux基础简介。
  10. HTTP/2:更快的页面加载时间[每日前端夜话0