I am trying to simplify the following part:
Host sandbox*
Port 22
User myUser
ProxyCommand=nc -X 5 -x gateway.test.io:1080 %h %p
Host sandbox9
HostName 1.0.9.10
Host sandbox10
HostName 1.0.10.10
Host sandbox11
HostName 1.0.11.10
I read, that I can use %h in HostName, which would then look like that:
Host sandbox*
Port 22
User myUser
ProxyCommand=nc -X 5 -x gateway.test.io:1080 %h %p
HostName 1.0.%h.10
But then I get the following error when trying to use ssh:
❯ ssh sandbox9
nc: connection failed, SOCKS error 8
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
ChatGPT first told me that the first approach should work, but then tells me this:
The %h placeholder cannot be directly used in the HostName directive of the SSH configuration file to substitute a variable for the hostname. Using placeholders in this specific directive is not supported.
Am I doing something wrong?
ssh sandbox9
, tries to connect to1.0.sandbox9.10
. – Kusalananda May 10 '23 at 14:44man ssh
, you will be pointed atman ssh_config
(or you directly go there, because you already know where to look), and it says exactly which placeholders you can use. Same for documentation ofnc
.man nc
tells us that-x gateway.test.io:1080
tellsnc
to dump communication as hexdump to a file called "gateway.test.io:1080". Was that what you set out to do? – Marcus Müller May 10 '23 at 14:53nc
out there: the original linuxops one, the nmap one, and the GNU one; on most systems I encounter, you get the nmapnetcat
as defaultnc
, and that's lead to trouble more than once, hence I'm mentioning it) – Marcus Müller May 10 '23 at 14:59