OpenSSH为给定的主机名称禁用ControlMaster

我正在使用OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011与Mac OS X Snow Leopard。 我有ControlMasterfunctionconfiguration为保持持久连接。 我的~/.ssh/config具有以下内容:

 Host * ControlPath /ms/%r@%h:%p ControlMaster auto ControlPersist 4h Host *.unfuddle.com ControlMaster no 

然而,从我所看到的 – 甚至当我试图使用SSH unfuddle.com主机,主连接始终创build:

 [andrey-mbp〜] $ ssh -v [email protected]
 OpenSSH_5.9p1,OpenSSL 0.9.8r 2011年2月8日
 debug1:读取configuration数据/Users/akhkharu/.ssh/config
 debug1:/Users/akhkharu/.ssh/config第1行:应用选项*
 debug1:/Users/akhkharu/.ssh/config第6行:为* .unfuddle.com应用选项
 debug1:读取configuration数据/usr/local/Cellar/openssh/5.9p1/etc/ssh_config
 debug1:自动多路复用器:尝试现有的主控器
 debug1:控制套接字“/ms/[email protected]:22”不存在
 debug1:连接到droolit.unfuddle.com [174.129.5.196]端口22。
 debug1:build立连接。
 debug1:身份文件/Users/akhkharu/.ssh/id_rsatypes1
 debug1:身份文件/Users/akhkharu/.ssh/id_rsa-certtypes-1
 debug1:身份文件/Users/akhkharu/.ssh/id_dsatypes2
 debug1:身份文件/Users/akhkharu/.ssh/id_dsa-certtypes-1
 debug1:身份文件/Users/akhkharu/.ssh/id_ecdsatypes-1
 debug1:身份文件/Users/akhkharu/.ssh/id_ecdsa-certtypes-1
 debug1:远程协议版本2.0,远程软件版本OpenSSH_5.8
 debug1:match:OpenSSH_5.8 pat OpenSSH *
 debug1:启用协议2.0的兼容模式
 debug1:本地版本stringSSH-2.0-OpenSSH_5.9
 debug1:发送SSH2_MSG_KEXINIT
debugging1:收到SSH2_MSG_KEXINIT
 debug1:kex:server-> client aes128-ctr hmac-md5 none
 debug1:kex:client-> server aes128-ctr hmac-md5 none
 debug1:发送SSH2_MSG_KEX_ECDH_INIT
 debug1:期待SSH2_MSG_KEX_ECDH_REPLY
 debug1:服务器主机密钥:RSA a6:74:33:36:95:31:6e:a6:d7:71:87:b8:3c:38:e2:60
 debug1:主机'droolit.unfuddle.com'是已知的并且与RSA主机密钥匹配。
 debug1:在/Users/akhkharu/.ssh/known_hosts:390find密钥
 debug1:ssh_rsa_verify:签名正确
 debug1:发送了SSH2_MSG_NEWKEYS
 debug1:期待SSH2_MSG_NEWKEYS
 debug1:收到SSH2_MSG_NEWKEYS
 debug1:服务器不允许漫游
debugging1:发送了SSH2_MSG_SERVICE_REQUEST
 debug1:收到SSH2_MSG_SERVICE_ACCEPT
 debug1:可以继续的身份validation:publickey
 debug1:下一个validation方法:publickey
 debug1:提供RSA公钥:/Users/akhkharu/.ssh/id_rsa
 debug1:服务器接受密钥:pkalg ssh-rsa mix 277
 debug1:authentication成功(publickey)。
validation到droolit.unfuddle.com([174.129.5.196]:22)。
 debug1:设置Multiplex主插口
 debug1:channel 0:new [/ms/[email protected]:22]
 debug1:control_persist_detach:后台主进程
 debug1:分叉到后台
 debug1:进入交互式会话。
 debug1:复用控制连接
debugging1:通道1:新[多路复用控制]
 debug1:通道2:新[client-session]
 debug1:远程:强制命令。
 debug1:远程:禁用端口转发。
 debug1:远程:禁用X11转发。
 debug1:远程:代理转发已禁用。
 debug1:远程:禁用Pty分配。
 debug1:远程:强制命令。
 debug1:远程:禁用端口转发。
 debug1:远程:禁用X11转发。
 debug1:远程:代理转发已禁用。
 debug1:远程:禁用Pty分配。
 debug1:mux_client_request_session:主会话ID:2
 PTY分配请求失败
需要SSH_ORIGINAL_COMMAND
 debug1:client_input_channel_req:channel 2 rtype退出状态回复0
 debug1:client_input_channel_req:channel 2 rtype [email protected]回复0
 debug1:channel 2:free:client-session,nchannels 3
 debug1:通道1:空闲:多路复用控制,n通道2
与droolit.unfuddle.com的共享连接已closures。
 [andrey-mbp〜] $ ll / ms /
总计0
 srw ------- 1 akhkharu admin 0B Jul 17 11:55 [email protected]:22

谢谢,
安德烈。

你的*主机节正在赶上它。 早些时候放置更具体的主机节。

正如SuperUser上的类似问题的答案中所述,您可以使用“bang”语法从原始Host *节中排除特定的主机,如下所示:

 Host * !*.unfuddle.com ControlPath /ms/%r@%h:%p ControlMaster auto ControlPersist 4h 

在我的情况下,我发现Host部分在使用Host *时的顺序似乎是不相关的,但上述方法总是有效的。

对于我来说,当我在host节中另外设置ControlPathnone时,它是有效的。

你可以试试:

 Host *.unfuddle.com ControlMaster no ControlPath none 

那么将不会生成控制会话。