我在OS X 10.5上使用PowerMac(PowerPC)进行测试。苹果已经放弃了对它的支持。其他人希望访问该盒子进行测试,因此我需要构建和安装更新的OpenSSH。
我访问了openssh.com,并通过FTP获取了最新版本(7.1)。左侧边栏中的链接。主页上没有下载链接;你一定要翻找它。
不幸的是,OpenSSH似乎缺少有关该过程的文档。否configure
(so no configure --help
),没有INSTALL,并且在OpenSSH FAQ中没有关于它的主题。
有一个自述文件,将我指向http://www.openssh.com/portable.html。不幸的是,它不提供构建说明。有趣的是,它确实对既有的会谈configure
,并autoreconf
认为不存在于压缩包。
我需要使用OpenSSL的更新版本。OpenSSL 1.0.2d已在中构建并安装/usr/local
。我还需要确保OpenSSH静态链接到备用OpenSSL,以便它不使用Apple提供的OpenSSL 0.9.8的较低版本。
如何在OS X上使用更新的OpenSSL构建OpenSSH?在哪里可以找到说明?
如何在OS X上使用更新的OpenSSL构建OpenSSH?在哪里可以找到说明?
Grawity是正确的-我下载了错误的OpenSSH。我需要一个便携式的,而不是FTP链接中提供的一个。可移植的列表在Portable OpenSSH的底部列出。
携带便携式电脑后,请打开包装,然后执行以下操作。下面假设你有一个更新的OpenSSLlibcrypto
安装在/usr/local/ssl/darwin
和更新的Zliblibz
的/usr/local
。调整它们以适合您的口味。
将-lz替换为存档的绝对路径
这是确保静态链接所必需的,因为在中没有明显的选项configure
。构建二进制文件时,otool -L
将显示没有外部Zlib依赖项。
$ grep "\-lz" *
configure:{ echo "$as_me:$LINENO: checking for deflate in -lz" >&5
configure:echo $ECHO_N "checking for deflate in -lz... $ECHO_C" >&6; }
configure:LIBS="-lz $LIBS"
configure: LIBS="-lz $LIBS"
configure: LIBS="$LIBS -lz"
configure.ac: LIBS="$LIBS -lz"
然后:
$ sed -i "" 's|-lz|/usr/local/lib/libz.a|g' config.h.in configure configure.ac
$
将-lcrypto替换为存档的绝对路径
这是确保静态链接所必需的,因为在中没有明显的选项configure
。构建二进制文件时,otool -L
将显示没有外部OpenSSL依赖项。
$ grep "\-lcrypto" *
configure: LIBS="-lcrypto $LIBS"
configure.ac: LIBS="-lcrypto $LIBS"
然后:
$ sed -i "" 's|-lcrypto|/usr/local/ssl/darwin/lib/libcrypto.a|g' configure configure.ac
$
在上文中,我使用/usr/local/ssl/darwin
的--openssldir
建设OpenSSL库时。它通常只是/usr/local/ssl
。根据需要进行调整。
配置OpenSSH
使用所需的路径配置OpenSSH。您可能还需要包括OS X库。
如果find /usr/lib/ -name libsandbox*
返回libsandbox.dylib
,则需要包括在内--with-libs="-lsandbox
。它在OS X 10.5上丢失,但在OS X 10.8上存在。如果该库存在但--with-libs
被省略,则将导致类似于的错误riemann.local sshd[15748]: fatal: ssh_sandbox_child: sandbox_init: dlopen(/usr/lib/libsandbox.1.dylib, 261): image not found [preauth]
。
$ ./configure --without-ssh1 --with-ssl-dir=/usr/local/ssl/darwin --with-zlib=/usr/local \
--with-libs="-lsandbox" --prefix=/usr/local
checking for gcc... gcc
checking for C compiler default output file name... a.out
...
OpenSSH has been configured with the following options:
User binaries: /usr/local/bin
System binaries: /usr/local/sbin
Configuration files: /usr/local/etc
...
Host: x86_64-apple-darwin12.6.0
Compiler: gcc
Compiler flags: -g -O2 -Qunused-arguments -Wunknown-warning-option -Wall -Wpointer-arith
-Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess
-Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2
-ftrapv -fno-builtin-memset -fstack-protector-all -fPIE
Preprocessor flags: -I/usr/local/ssl/darwin/include -I/usr/local/include
Linker flags: -L/usr/local/ssl/darwin/lib -L/usr/local/lib -fstack-protector-all -pie
Libraries: /usr/local/ssl/darwin/lib/libcrypto.a /usr/local/lib/libz.a -lsandbox -lresolv
您可能需要--with-pam
使密码身份验证正常工作。我不关心该功能,因此未添加配置选项。
编译并安装OpenSSH
-fwrapv
当在高完整性软件中查看时,这有些麻烦。这通常意味着存在一个非法的C程序,该程序具有不确定的行为。开发人员尚未修复它,因此他们-fwrapv
用作创可贴。
$ make
conffile=`echo sshd_config.out | sed 's/.out$//'`; \
...
gcc -g -O2 -Qunused-arguments -Wunknown-warning-option -Wall -Wpointer-arith -Wuninitialized
-Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign
-Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset
-fstack-protector-all -fPIE -I. -I.. -I. -I./.. -I/usr/local/ssl/darwin/include
-I/usr/local/include -DHAVE_CONFIG_H -c arc4random.c
gcc -g -O2 -Qunused-arguments -Wunknown-warning-option -Wall -Wpointer-arith -Wuninitialized
-Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign
-Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset
-fstack-protector-all -fPIE -I. -I.. -I. -I./.. -I/usr/local/ssl/darwin/include
-I/usr/local/include -DHAVE_CONFIG_H -c bsd-asprintf.c
...
外部依赖关系(或缺少外部依赖关系)可以通过以下方式验证:
$ otool -L ./sshd
./sshd:
/usr/lib/libsandbox.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
不幸的是,没有make check
或没有make test
目标,因此没有明显的方法可以在安装软件之前对其进行测试。
$ sudo make install
...
Generating public/private ed25519 key pair.
Your identification has been saved in /usr/local/etc/ssh_host_ed25519_key.
Your public key has been saved in /usr/local/etc/ssh_host_ed25519_key.pub.
The key fingerprint is:
SHA256:u/xQ6haFqxjG0fBgSMt0W58N8zmhu+NmyQxNMkMcwPc [email protected]
The key's randomart image is:
+--[ED25519 256]--+
| .ooooo.o . |
| o.o=o+. B o |
| o..B .+.= |
| . * E... |
| . . *So. |
| + . += |
| . o =*o |
| . .+B+ |
| +=.. |
+----[SHA256]-----+
...
为新的SSH二进制文件创建一个Plist
以下代码使用现有的ssh.plist
,删除Apple包装脚本,并更改端口号。将其复制到/System/Library/LaunchDaemons/ssh-7.1.plist
。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>com.openssh.sshd.7-1</string>
<key>Program</key>
<string>/usr/local/sbin/sshd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/sshd</string>
<string>-i</string>
<string>-e</string>
<string>-f</string>
<string>/usr/local/etc/sshd_config</string>
<string>-o</string>
<string>PidFile=/var/run/sshd-7.1.pid</string>
</array>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>1522</string>
</dict>
</dict>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
<key>StandardErrorPath</key>
<string>/var/log/sshd-7.1.log</string>
<key>SHAuthorizationRight</key>
<string>system.preferences</string>
</dict>
</plist>
plist中发生了一些事情:
com.openssh.sshd.7-1
以避免与Apple的冲突com.openssh.sshd
var/run/sshd-7.1.pid
以避免与Apple的文件冲突var/run/sshd.pid
ProgramArguments
原因是需要sshd re-exec requires execution with an absolute path
为客户端连接提供服务sshd_config
为避免公开的问题和混乱而特别呼吁。但默认情况下使用i
选项的使用,即使它是一个inetd(8)
选项。根据OS X上的sshd和-i选项,应使用启动新的SSH服务
使用启动来启动服务。请注意,由于已禁用服务,因此使用-w
来避免出现“找不到要加载的内容”错误消息。
$ sudo launchctl load -w /System/Library/LaunchDaemons/ssh-7.1.plist
最后,确认新的SSH服务器正在运行:
$ netstat -an | grep 1522
tcp6 0 0 *.1522 *.* LISTEN
tcp4 0 0 *.1522 *.* LISTEN
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句