Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ssh 远程shell命令作业无法解决Azure发布管道中的主机名问题_Ssh_Azure Devops - Fatal编程技术网

Ssh 远程shell命令作业无法解决Azure发布管道中的主机名问题

Ssh 远程shell命令作业无法解决Azure发布管道中的主机名问题,ssh,azure-devops,Ssh,Azure Devops,我有一个Azure发布管道,它使用Azure管道代理池(ubuntu-20.04)。我试图使用SSH部署任务在使用SSH密钥进行身份验证的远程服务器中执行远程shell命令。作为安全措施,只能通过“跳转服务器”访问远程服务器。我使用安装SSH密钥任务来安装相应的SSH密钥。尽管如此,我在installssh-Key任务中发现的一个限制是,我只能提供一个SSH-config条目,但我需要指定两个条目,并另外使用ProxyCommand指令。SSH配置文件应如下所示: Host jump User

我有一个Azure发布管道,它使用Azure管道代理池(ubuntu-20.04)。我试图使用SSH部署任务在使用SSH密钥进行身份验证的远程服务器中执行远程shell命令。作为安全措施,只能通过“跳转服务器”访问远程服务器。我使用安装SSH密钥任务来安装相应的SSH密钥。尽管如此,我在installssh-Key任务中发现的一个限制是,我只能提供一个SSH-config条目,但我需要指定两个条目,并另外使用ProxyCommand指令。SSH配置文件应如下所示:

Host jump
 User myuser
 IdentityFile /home/vsts/work/_temp/key
 Hostname server.host
 Port xxx

Host myserver
 User myuser
 Port xxx
 IdentityFile /home/vsts/work/_temp/key
 ProxyCommand ssh -W %h:%p jump
由于我无法使用Install SSH Key任务的“Add entry to SSH config”部分来添加这些配置,因此我使用“Copy Files”作业将相应的SSH配置文件复制到/home/vsts/.SSH。我在“命令行脚本”任务中测试了执行
ssh-vvv
的配置,代理似乎能够成功连接到服务器:

2020-09-02T12:24:55.7633039Z *** ssh -vvvv <server>
2020-09-02T12:24:55.7700399Z OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
2020-09-02T12:24:55.7703535Z debug1: Reading configuration data /home/vsts/.ssh/config
2020-09-02T12:24:55.7703945Z debug1: /home/vsts/.ssh/config line 7: Applying options for myserver
2020-09-02T12:24:55.7704289Z debug1: Reading configuration data /etc/ssh/ssh_config
2020-09-02T12:24:55.7706120Z debug1: /etc/ssh/ssh_config line 19: Applying options for *
2020-09-02T12:24:55.7707283Z Pseudo-terminal will not be allocated because stdin is not a terminal.
2020-09-02T12:24:55.7709690Z debug1: Executing proxy command: exec ssh -W <server>:<port> jump
2020-09-02T12:24:55.7713467Z debug1: permanently_drop_suid: 1001
2020-09-02T12:24:55.7715841Z debug1: identity file /home/vsts/work/_temp/key type 0
2020-09-02T12:24:55.7716186Z debug1: key_load_public: No such file or directory
2020-09-02T12:24:55.7716840Z debug1: identity file /home/vsts/work/_temp/key-cert type -1
2020-09-02T12:24:55.7718876Z debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
2020-09-02T12:24:56.3441004Z debug1: Remote protocol version 2.0, remote software version OpenSSH_8.0
2020-09-02T12:24:56.3441741Z debug1: match: OpenSSH_8.0 pat OpenSSH* compat 0x04000000
2020-09-02T12:24:56.3442275Z debug2: fd 5 setting O_NONBLOCK
2020-09-02T12:24:56.3442684Z debug2: fd 4 setting O_NONBLOCK
2020-09-02T12:24:56.3444286Z debug1: Authenticating to <server>:<port> as 'myuser'
2020-09-02T12:24:56.3444832Z debug3: put_host_port: [<server>]:<port>
2020-09-02T12:24:56.3445417Z debug3: hostkeys_foreach: reading file "/home/vsts/.ssh/known_hosts"
2020-09-02T12:24:56.3446488Z debug3: record_hostkey: found key type ECDSA in file /home/vsts/.ssh/known_hosts:3
2020-09-02T12:24:56.3447226Z debug3: load_hostkeys: loaded 1 keys from [<server>]:<port>
...
2020-09-02T12:24:56.5726006Z debug2: channel_input_open_confirmation: channel 0: callback done
2020-09-02T12:24:56.5726381Z debug2: channel 0: open confirm rwindow 0 rmax 32768
2020-09-02T12:24:56.5772512Z debug2: channel 0: rcvd adjust 2097152
2020-09-02T12:24:56.5772991Z debug3: receive packet: type 99
2020-09-02T12:24:56.5773256Z debug2: channel_input_status_confirm: type 99 id 0
2020-09-02T12:24:56.5773526Z debug2: shell request accepted on channel 0
2020-09-02T12:24:55.7633039Z***ssh-vvv
2020-09-02T12:24:55.7700399Z OpenSSH_7.6p1 Ubuntu-4ubuntu0.3,OpenSSL 1.0.2n 2017年12月7日
2020-09-02T12:24:55.7703535Z调试1:正在读取配置数据/home/vsts/.ssh/config
2020-09-02T12:24:55.7703945Z调试1:/home/vsts/.ssh/config第7行:为myserver应用选项
2020-09-02T12:24:55.7704289Z调试1:读取配置数据/etc/ssh/ssh_config
2020-09-02T12:24:55.7706120Z调试1:/etc/ssh/ssh_配置行19:应用*
2020-09-02T12:24:55.7707283Z伪终端将不被分配,因为stdin不是终端。
2020-09-02T12:24:55.7709690Z调试1:执行代理命令:exec ssh-W:jump
2020-09-02T12:24:55.7713467Z调试1:永久性下降
2020-09-02T12:24:55.7715841Z调试1:标识文件/主页/vsts/工作/_临时/密钥类型0
2020-09-02T12:24:55.7716186Z调试1:key\u load\u public:没有这样的文件或目录
2020-09-02T12:24:55.7716840Z调试1:身份文件/home/vsts/work/_temp/密钥证书类型-1
2020-09-02T12:24:55.7718876Z调试1:本地版本字符串SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
2020-09-02T12:24:56.3441004Z调试1:远程协议版本2.0,远程软件版本OpenSSH_8.0
2020-09-02T12:24:56.3441741Z调试1:match:OpenSSH_8.0 pat OpenSSH*compat 0x04000000
2020-09-02T12:24:56.3442275Z调试2:fd 5设置非块
2020-09-02T12:24:56.3442684Z调试2:fd 4设置O_非块
2020-09-02T12:24:56.3444286Z调试1:身份验证到:作为“myuser”
2020-09-02T12:24:56.3444832Z调试3:put_主机_端口:[]:
2020-09-02T12:24:56.3445417Z调试3:hostkeys\u foreach:读取文件“/home/vsts/.ssh/known\u hosts”
2020-09-02T12:24:56.3446488Z调试3:记录主机密钥:在文件/home/vsts/.ssh/known\u hosts:3中找到密钥类型ECDSA
2020-09-02T12:24:56.3447226Z调试3:加载主机密钥:从[]加载1个密钥:
...
2020-09-02T12:24:56.5726006Z调试2:通道输入打开确认:通道0:回调完成
2020-09-02T12:24:56.5726381Z调试2:通道0:打开确认rwindow 0 rmax 32768
2020-09-02T12:24:56.5772512Z调试2:通道0:rcvd调整2097152
2020-09-02T12:24:56.5772991Z调试3:接收数据包:类型99
2020-09-02T12:24:56.5773256Z调试2:通道输入状态确认:类型99 id 0
2020-09-02T12:24:56.5773526Z调试2:在通道0上接受shell请求
然而,当SSH部署任务尝试连接时,我收到以下异常:

2020-09-02T12:02:40.8497381Z ##[error]Failed to connect to remote machine. Verify the SSH service connection details. Error: Error: getaddrinfo EAI_AGAIN <server>:<port>.
2020-09-02T12:02:40.8497381Z##[错误]无法连接到远程计算机。验证SSH服务连接详细信息。错误:错误:getaddrinfo EAI\u再次:。
SSH部署任务使用的服务连接正确。我怀疑这与SSH配置有关,因为getaddrinfo错误表明远程服务器的DNS解析失败


我知道我可以尝试使用私有代理池,但我想把它作为最后一个资源。是否有人建议我如何修复该错误?

也许您可以参考此内容,看看是否有帮助。尝试更改另一个端口。我以前看过那篇文章,但端口是正确的。实际上,我可以使用“命令行”任务和ssh-t命令连接到远程服务器,以执行我想要执行的任务。这意味着安装SSH密钥工作正常。我想问题在于“SSH部署”任务如何处理自定义SSH配置