0

I wish to have this all done in the ssh config file for a specific user. The site has hard-coded ip addresses into there various software and using the naming convention is not really an option.

Host bast.aws1.prod
  HostName bastion.aws1.chaos.com
  User chaos

Host *.aws1.prod
  User chaos
  Proxycommand ssh bast.aws1.prod -W 192.168.10.`echo %h | cut -d. -f1`:%p

Host bast.aws2.prod
  HostName bastion.aws2.chaos.com
  User chaos

Host *.aws2.prod
  User chaos
  Proxycommand ssh bast.aws2.prod -W 192.168.12.`echo %h | cut -d. -f1`:%p

So if I run the following command:

ssh 169.aws2.prod it should execute within the proxy command "ssh bast.aws2.prod -W 192.168.12.169:22"

but it executes "ssh bast.aws2.prod -W 192.168.12.echo %h | cut -d. -f1:22" instead.

What is the best way to pass the last octet to the value within the proxycommand? Alternative ways are welcome.

4
  • Try using: cut -d'.' -f1
    – JayCravens
    Commented May 17 at 19:42
  • Tried that Jay, no joy. Strange how it works fine with a name on other servers. Maybe I will look if there is a function to convert all to a ip address - not sure if there is a string variable interfering.
    – Chaos
    Commented May 20 at 8:58
  • Where is the 169:22 coming from?
    – JayCravens
    Commented May 25 at 22:57
  • 169 will be the last octet I specify thus replacing the * in the *.aws2.prod option I type and :22 is the default port for ssh which is included by default.
    – Chaos
    Commented Jun 16 at 19:53

0

You must log in to answer this question.

Browse other questions tagged .