Ubuntu升级OpenSSH至安全版本9.8

打印 上一主题 下一主题

主题 917|帖子 917|积分 2751

  1. 下载地址
  2. OpenSSH
  3. 官方安装步骤在最后
  4. /lib/systemd/system/ssh.service
  5. [Unit]
  6. Description=OpenBSD Secure Shell server
  7. Documentation=man:sshd(8) man:sshd_config(5)
  8. After=network.target auditd.service
  9. ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
  10. [Service]
  11. EnvironmentFile=-/etc/default/ssh
  12. ExecStartPre=/usr/local/sbin/sshd -t
  13. ExecStart=/usr/local/sbin/sshd -D $SSHD_OPTS
  14. ExecReload=/usr/local/sbin/sshd -t
  15. ExecReload=/bin/kill -HUP $MAINPID
  16. KillMode=process
  17. Restart=on-failure
  18. RestartPreventExitStatus=255
  19. Type=notify
  20. RuntimeDirectory=sshd
  21. RuntimeDirectoryMode=0755
  22. [Install]
  23. WantedBy=multi-user.target
  24. Alias=sshd.service
  25. 测试:
  26. ./poc 172.19.157.208 22
  27. - hosts: 172.23.5.191
  28.   tasks:
  29.     - name: Copy openssh tarball to remote host
  30.       copy:
  31.         src: /data/ansible/ssh/openssh-9.8p1.tar.gz
  32.         dest: /tmp/
  33.     - name: Extract openssh tarball
  34.       unarchive:
  35.         src: /tmp/openssh-9.8p1.tar.gz
  36.         dest: /tmp/
  37.         remote_src: yes
  38.     - name: Configure openssh
  39.       command: ./configure
  40.       args:
  41.         chdir: /tmp/openssh-9.8p1
  42.     - name: Compile openssh
  43.       command: make
  44.       args:
  45.         chdir: /tmp/openssh-9.8p1
  46.     - name: Install openssh
  47.       command: make install
  48.       args:
  49.         chdir: /tmp/openssh-9.8p1
  50. - name: Copy ssh.service file to remote servers
  51.   hosts:
  52.     - test
  53.     - stage
  54.   tasks:
  55.     - name: Copy ssh.service file
  56.       copy:
  57.         src: /data/ansible/ssh/ssh.service
  58.         dest: /lib/systemd/system/ssh.service
  59.         owner: root
  60.         group: root
  61.         mode: '0644'
  62.       become: yes
  63.     - name: Copy sshd_config file
  64.       copy:
  65.         src: /data/ansible/ssh/sshd_config
  66.         dest: /usr/local/etc/sshd_config
  67.         owner: root
  68.         group: root
  69.         mode: '0644'
  70.       become: yes
  71.     - name: Restart SSH service
  72.       systemd:
  73.         name: sshd
  74.         state: restarted
  75.         daemon_reload: yes
  76.       become: yes
  77. 1. Prerequisites
  78. ----------------
  79. A C compiler.  Any C89 or better compiler that supports variadic macros
  80. should work.  Where supported, configure will attempt to enable the
  81. compiler's run-time integrity checking options.  Some notes about
  82. specific compilers:
  83. - clang: -ftrapv and -sanitize=integer require the compiler-rt runtime
  84.   (CC=clang LDFLAGS=--rtlib=compiler-rt ./configure)
  85. To support Privilege Separation (which is now required) you will need
  86. to create the user, group and directory used by sshd for privilege
  87. separation.  See README.privsep for details.
  88. The remaining items are optional.
  89. A working installation of zlib:
  90. Zlib 1.1.4 or 1.2.1.2 or greater (earlier 1.2.x versions have problems):
  91. https://zlib.net/
  92. libcrypto from either of LibreSSL or OpenSSL.  Building without libcrypto
  93. is supported but severely restricts the available ciphers and algorithms.
  94. - LibreSSL (https://www.libressl.org/) 3.1.0 or greater
  95. - OpenSSL (https://www.openssl.org) 1.1.1 or greater
  96. LibreSSL/OpenSSL should be compiled as a position-independent library
  97. (i.e. -fPIC, eg by configuring OpenSSL as "./config [options] -fPIC"
  98. or LibreSSL as "CFLAGS=-fPIC ./configure") otherwise OpenSSH will not
  99. be able to link with it.  If you must use a non-position-independent
  100. libcrypto, then you may need to configure OpenSSH --without-pie.
  101. If you build either from source, running the OpenSSL self-test ("make
  102. tests") or the LibreSSL equivalent ("make check") and ensuring that all
  103. tests pass is strongly recommended.
  104. NB. If you operating system supports /dev/random, you should configure
  105. libcrypto (LibreSSL/OpenSSL) to use it. OpenSSH relies on libcrypto's
  106. direct support of /dev/random, or failing that, either prngd or egd.
  107. PRNGD:
  108. If your system lacks kernel-based random collection, the use of Lutz
  109. Jaenicke's PRNGd is recommended. It requires that libcrypto be configured
  110. to support it.
  111. http://prngd.sourceforge.net/
  112. EGD:
  113. The Entropy Gathering Daemon (EGD) supports the same interface as prngd.
  114. It also supported only if libcrypto is configured to support it.
  115. http://egd.sourceforge.net/
  116. PAM:
  117. OpenSSH can utilise Pluggable Authentication Modules (PAM) if your
  118. system supports it. PAM is standard most Linux distributions, Solaris,
  119. HP-UX 11, AIX >= 5.2, FreeBSD, NetBSD and Mac OS X.
  120. Information about the various PAM implementations are available:
  121. Solaris PAM:        http://www.sun.com/software/solaris/pam/
  122. Linux PAM:        http://www.kernel.org/pub/linux/libs/pam/
  123. OpenPAM:        http://www.openpam.org/
  124. If you wish to build the GNOME passphrase requester, you will need the GNOME
  125. libraries and headers.
  126. GNOME:
  127. http://www.gnome.org/
  128. Alternatively, Jim Knoble <jmknoble@pobox.com> has written an excellent X11
  129. passphrase requester. This is maintained separately at:
  130. http://www.jmknoble.net/software/x11-ssh-askpass/
  131. LibEdit:
  132. sftp supports command-line editing via NetBSD's libedit.  If your platform
  133. has it available natively you can use that, alternatively you might try
  134. these multi-platform ports:
  135. http://www.thrysoee.dk/editline/
  136. http://sourceforge.net/projects/libedit/
  137. LDNS:
  138. LDNS is a DNS BSD-licensed resolver library which supports DNSSEC.
  139. http://nlnetlabs.nl/projects/ldns/
  140. Autoconf:
  141. If you modify configure.ac or configure doesn't exist (eg if you checked
  142. the code out of git yourself) then you will need autoconf-2.69 and
  143. automake-1.16.1 to rebuild the automatically generated files by running
  144. "autoreconf".  Earlier versions may also work but this is not guaranteed.
  145. http://www.gnu.org/software/autoconf/
  146. http://www.gnu.org/software/automake/
  147. Basic Security Module (BSM):
  148. Native BSM support is known to exist in Solaris from at least 2.5.1,
  149. FreeBSD 6.1 and OS X.  Alternatively, you may use the OpenBSM
  150. implementation (http://www.openbsm.org).
  151. makedepend:
  152. https://www.x.org/archive/individual/util/
  153. If you are making significant changes to the code you may need to rebuild
  154. the dependency (.depend) file using "make depend", which requires the
  155. "makedepend" tool from the X11 distribution.
  156. libfido2:
  157. libfido2 allows the use of hardware security keys over USB.  libfido2
  158. in turn depends on libcbor.  libfido2 >= 1.5.0 is strongly recommended.
  159. Limited functionality is possible with earlier libfido2 versions.
  160. https://github.com/Yubico/libfido2
  161. https://github.com/pjk/libcbor
  162. 2. Building / Installation
  163. --------------------------
  164. To install OpenSSH with default options:
  165. ./configure
  166. make
  167. make install
  168. This will install the OpenSSH binaries in /usr/local/bin, configuration files
  169. in /usr/local/etc, the server in /usr/local/sbin, etc. To specify a different
  170. installation prefix, use the --prefix option to configure:
  171. ./configure --prefix=/opt
  172. make
  173. make install
  174. Will install OpenSSH in /opt/{bin,etc,lib,sbin}. You can also override
  175. specific paths, for example:
  176. ./configure --prefix=/opt --sysconfdir=/etc/ssh
  177. make
  178. make install
  179. This will install the binaries in /opt/{bin,lib,sbin}, but will place the
  180. configuration files in /etc/ssh.
  181. If you are using PAM, you may need to manually install a PAM control
  182. file as "/etc/pam.d/sshd" (or wherever your system prefers to keep
  183. them).  Note that the service name used to start PAM is __progname,
  184. which is the basename of the path of your sshd (e.g., the service name
  185. for /usr/sbin/osshd will be osshd).  If you have renamed your sshd
  186. executable, your PAM configuration may need to be modified.
  187. A generic PAM configuration is included as "contrib/sshd.pam.generic",
  188. you may need to edit it before using it on your system. If you are
  189. using a recent version of Red Hat Linux, the config file in
  190. contrib/redhat/sshd.pam should be more useful.  Failure to install a
  191. valid PAM file may result in an inability to use password
  192. authentication.  On HP-UX 11 and Solaris, the standard /etc/pam.conf
  193. configuration will work with sshd (sshd will match the other service
  194. name).
  195. There are a few other options to the configure script:
  196. --with-audit=[module] enable additional auditing via the specified module.
  197. Currently, drivers for "debug" (additional info via syslog) and "bsm"
  198. (Sun's Basic Security Module) are supported.
  199. --with-pam enables PAM support. If PAM support is compiled in, it must
  200. also be enabled in sshd_config (refer to the UsePAM directive).
  201. --with-prngd-socket=/some/file allows you to enable EGD or PRNGD
  202. support and to specify a PRNGd socket. Use this if your Unix lacks
  203. /dev/random.
  204. --with-prngd-port=portnum allows you to enable EGD or PRNGD support
  205. and to specify a EGD localhost TCP port. Use this if your Unix lacks
  206. /dev/random.
  207. --with-lastlog=FILE will specify the location of the lastlog file.
  208. ./configure searches a few locations for lastlog, but may not find
  209. it if lastlog is installed in a different place.
  210. --without-lastlog will disable lastlog support entirely.
  211. --with-osfsia, --without-osfsia will enable or disable OSF1's Security
  212. Integration Architecture.  The default for OSF1 machines is enable.
  213. --with-utmpx enables utmpx support. utmpx support is automatic for
  214. some platforms.
  215. --without-shadow disables shadow password support.
  216. --with-ipaddr-display forces the use of a numeric IP address in the
  217. $DISPLAY environment variable. Some broken systems need this.
  218. --with-default-path=PATH allows you to specify a default $PATH for sessions
  219. started by sshd. This replaces the standard path entirely.
  220. --with-pid-dir=PATH specifies the directory in which the sshd.pid file is
  221. created.
  222. --with-xauth=PATH specifies the location of the xauth binary
  223. --with-ssl-dir=DIR allows you to specify where your Libre/OpenSSL
  224. libraries are installed.
  225. --with-ssl-engine enables Libre/OpenSSL's (hardware) ENGINE support
  226. --without-openssl builds without using OpenSSL.  Only a subset of ciphers
  227. and algorithms are supported in this configuration.
  228. --without-zlib builds without zlib.  This disables the Compression option.
  229. --with-4in6 Check for IPv4 in IPv6 mapped addresses and convert them to
  230. real (AF_INET) IPv4 addresses. Works around some quirks on Linux.
  231. If you need to pass special options to the compiler or linker, you
  232. can specify these as environment variables before running ./configure.
  233. For example:
  234. CC="/usr/foo/cc" CFLAGS="-O" LDFLAGS="-s" LIBS="-lrubbish" ./configure
  235. 3. Configuration
  236. ----------------
  237. The runtime configuration files are installed by in ${prefix}/etc or
  238. whatever you specified as your --sysconfdir (/usr/local/etc by default).
  239. The default configuration should be instantly usable, though you should
  240. review it to ensure that it matches your security requirements.
  241. To generate a host key, run "make host-key". Alternately you can do so
  242. manually using the following commands:
  243.     ssh-keygen -t [type] -f /etc/ssh/ssh_host_key -N ""
  244. for each of the types you wish to generate (rsa, dsa or ecdsa) or
  245.     ssh-keygen -A
  246. to generate keys for all supported types.
  247. Replacing /etc/ssh with the correct path to the configuration directory.
  248. (${prefix}/etc or whatever you specified with --sysconfdir during
  249. configuration).
  250. If you have configured OpenSSH with EGD/prngd support, ensure that EGD or
  251. prngd is running and has collected some entropy first.
  252. For more information on configuration, please refer to the manual pages
  253. for sshd, ssh and ssh-agent.
  254. 4. (Optional) Send survey
  255. -------------------------
  256. $ make survey
  257. [check the contents of the file "survey" to ensure there's no information
  258. that you consider sensitive]
  259. $ make send-survey
  260. This will send configuration information for the currently configured
  261. host to a survey address.  This will help determine which configurations
  262. are actually in use, and what valid combinations of configure options
  263. exist.  The raw data is available only to the OpenSSH developers, however
  264. summary data may be published.
  265. 5. Problems?
  266. ------------
  267. If you experience problems compiling, installing or running OpenSSH,
  268. please refer to the "reporting bugs" section of the webpage at
  269. https://www.openssh.com/
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

西河刘卡车医

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表