I had one a long time ago, from before ssh -W, which I updated for the occasion:<p>Host &lt;asterisk&gt;+&lt;asterisk&gt;<p>ProxyCommand ssh -W $(echo %h | sed &#x27;s&#x2F;^.&lt;asterisk&gt;+&#x2F;&#x2F;&#x27;) $(echo %h | sed &#x27;s&#x2F;+[^+]&lt;asterisk&gt;$&#x2F;&#x2F;;s&#x2F;\([^+%%]&lt;asterisk&gt;\)%%\([^+]&lt;asterisk&gt;\)$&#x2F;\2 -l \1&#x2F;;s&#x2F;:\([^:+]&lt;asterisk&gt;\)$&#x2F; -p \1&#x2F;&#x27;)<p>Use with:<p>$ ssh login1%host1:port1+login2%host2:port2+login3%host3:port3+host4:port4 -l login4<p><a href="https:&#x2F;&#x2F;glandium.org&#x2F;blog&#x2F;?p=3631" rel="nofollow">https:&#x2F;&#x2F;glandium.org&#x2F;blog&#x2F;?p=3631</a><p>Edit: there is apparently no way to escape asterisks, so I replaced them with &lt;asterisk&gt; (hopefully I didn&#x27;t miss one), but you&#x27;d better check out the link.