SSH – Fix Bad Stdio Forwarding Specification ‘%h:%p’ on macOS

macmacosssh

I am on macOS Sierra, and my SSH version is :
OpenSSH_7.5p1, OpenSSL 1.0.2l 25 May 2017

I have this content in my .ssh/config :

Host db
  User user
  HostName 192.168.1.111
  ProxyCommand ssh user@db -W %h:%p

Host website
  User user
  HostName 192.168.1.100
  ProxyCommand ssh user@Website -W %h:%p

I also have a server with a public IP, that has direct connection with these two servers, I want to forward my SSH connection through this public server to my private servers (db and website).

When I use this command:

ssh user@db -W %h:%p

I get this error:

Bad stdio forwarding specification '%h:%p'

Now, what should I do to solve this problem and connect my macOS host to my private servers?

Best Answer

Your config file as well as the command are wrong.

The ProxyCommand line should contain the JumpHost's user/hostname but not the final destination.

Config file:

Host db
  User dbuser
  HostName 192.168.1.111 #db host name/IP
  ProxyCommand ssh user_public_server@public_server -W %h:%p

Host website
  User websiteuser
  HostName 192.168.1.100 #website host name/IP
  ProxyCommand ssh user_public_server@public_server -W %h:%p

The command is then simply ssh db or ssh website because the user friendly Host's name (e.g. db) as defined in the config file is expanded to the HostName/IP (e.g. 192.168.1.111).