I have an Azure Release Pipeline which uses the Azure Pipelines Agent Pool (ubuntu-20.04). I am trying to use the SSH Deployment task to execute a remote shell command in a remote server that uses an SSH Key for authentication. That remote server can only be accessed through a "jump server" as a security measure. I used the Install SSH Key task to install the corresponding SSH Key. Nevertheless, a limitation that I found with the Install SSH Key task is that I can only provide a single SSH config entry, but I need to specify two and additionally use the ProxyCommand directive. The SSH Config file should look like this:
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
Since I cannot use the "Add entry to SSH config" section of the Install SSH Key task to add these configurations, I copied the corresponding SSH Config file using the "Copy Files" Job to /home/vsts/.ssh. I tested the configurations executing a ssh -vvvv <server>
in a "Command Line Script" task and the Agent seems to be able to connect to the server successfully:
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
Nevertheless, when the SSH Deployment task tries the connection, I receive the following exception:
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>.
The Service connection used by the SSH Deploy Task is correct. I suspect it has something to do with the SSH config, since the getaddrinfo error suggests that the DNS resolution for the remote server failed.
I know I could try using a Private Agent Pool, but I would like to leave that as the last resource. Does anyone have a suggestion how could I fix that error?