2015-10-16 49 views
1

我試圖配置我的SSH配置以實現更簡單的工作流程,但是我已經在此處運行。 我有一個跳轉主機,需要sudo ssh才能連接所有其他機器。無法使用代理服務器上的sudo獲得SSH ProxyCommand的工作

我已經想通了,如果我跑ssh -tt jumphost sudo ssh desthost,我從哪裏得到我的sudo密碼,我可以訪問desthost

現在,當我添加ProxyCommand ssh -tt jumphost sudo ssh %hssh_config和運行ssh desthost然後我就得到了一個空白連接。

調試打印輸出:

OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 
debug1: Reading configuration data /Users/deiga/.ssh/config 
debug1: /Users/deiga/.ssh/config line 34: Applying options for desthost 
debug1: /Users/deiga/.ssh/config line 167: Applying options for * 
debug1: Reading configuration data /etc/ssh_config 
debug1: /etc/ssh_config line 20: Applying options for * 
debug1: auto-mux: Trying existing master 
debug1: Control socket "/tmp/[email protected]:22" does not exist 
debug2: ssh_connect: needpriv 0 
debug1: Executing proxy command: exec ssh -tt jumphost sudo ssh desthost 
debug1: identity file /Users/deiga/.ssh/id_rsa type -1 
debug1: identity file /Users/deiga/.ssh/id_rsa-cert type -1 
debug1: identity file /Users/deiga/.ssh/id_dsa type -1 
debug1: identity file /Users/deiga/.ssh/id_dsa-cert type -1 
debug1: permanently_drop_suid: 501 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_6.2 
debug1: ssh_exchange_identification: [sudo] password for deiga: 

debug1: ssh_exchange_identification: Sorry, try again. 

debug1: ssh_exchange_identification: [sudo] password for deiga: 

debug1: ssh_exchange_identification: sudo: 1 incorrect password attempt 

回答

0

這不是如何代理指揮工作。基本的例子你應該怎麼做jumphosts是這樣的:

ProxyCommand ssh -W %h:%p jumphost 

它不支持在遠程機器上運行sudo。但是你可以做同樣的netcat的命令:

ProxyCommand ssh jumphost nc %h %p 

,並使其與您的sudo要求的工作,只需添加sudo命令:

ProxyCommand ssh jumphost sudo nc %h %p 

如果它不會幫助,請嘗試診斷來自ssh的詳細日誌的問題(-vvv)。

+1

我試過所有這些。但是jumphost需要一個tty來sudo,它需要sudo來連接到desthost。所以,如果我做'ProxyCommand ssh -tt jumphost sudo nc%h%p'我的ssh連接只是掛起而不要求輸入密碼或任何東西 – deiga

相關問題