gpt4 book ai didi

ssh - 无法在代理计算机上使用sudo获取SSH ProxyCommand

转载 作者:行者123 更新时间:2023-12-02 14:34:51 25 4
gpt4 key购买 nike

我试图配置SSH配置以简化工作流程,但在这里遇到了麻烦。
我有一个跳转主机,需要sudo ssh才能访问所有其他计算机。

我发现,如果我运行ssh -tt jumphost sudo ssh desthost,我会被要求输入我的sudo密码,并且可以访问desthost
现在,当我将ProxyCommand ssh -tt jumphost sudo ssh %h添加到我的ssh_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/ssh-deiga@desthost: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

最佳答案

这不是proxy命令的工作方式。这样的基本示例应该如何做:

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)的详细日志诊断问题。

关于ssh - 无法在代理计算机上使用sudo获取SSH ProxyCommand,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33165513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com