Sample Header Ad - 728x90

Placeholder in ssh config in HostName

0 votes
1 answer
536 views
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?
Asked by Mr.Tr33 (101 rep)
May 10, 2023, 02:35 PM
Last activity: Sep 23, 2023, 05:03 AM