Skip to main content
Commonmark migration
Source Link

I figured out a working method. It's a bit ugly, but it does work. This leverages the ProxyCommand directive (see [manpage][1]manpage) combined with a small bash helper script.

  1. Add sections like this to ~/.ssh/config — one for each domain you want remapped:
Match final host="!*.corp.foo.com,*.foo.com"
    ProxyCommand ssh_ext2int %h %p

Match final host="*.quux.biz"
    ProxyCommand ssh_ext2int %h %p
  1. Save this in your $PATH somewhere as ssh_ext2int — and chmod u+x it:
#!/usr/bin/env bash

[ $# -eq 2 ] || exit 1
typeset -A dmap
dmap=(
  [foo.com]=corp.foo.com
  [quux.biz]=internal.qux.lan
)

d=${1#*.}
h=${1%%.*}
nd=${dmap[$d]:-$d}

/usr/bin/nc -w 120 $h.$nd $2 2>/dev/null

Now, ssh server158247.quux.biz should connect you to server158247.internal.qux.lan [1]: https://man.openbsd.org/ssh_config#ProxyCommand

I figured out a working method. It's a bit ugly, but it does work. This leverages the ProxyCommand directive (see [manpage][1]) combined with a small bash helper script.

  1. Add sections like this to ~/.ssh/config — one for each domain you want remapped:
Match final host="!*.corp.foo.com,*.foo.com"
    ProxyCommand ssh_ext2int %h %p

Match final host="*.quux.biz"
    ProxyCommand ssh_ext2int %h %p
  1. Save this in your $PATH somewhere as ssh_ext2int — and chmod u+x it:
#!/usr/bin/env bash

[ $# -eq 2 ] || exit 1
typeset -A dmap
dmap=(
  [foo.com]=corp.foo.com
  [quux.biz]=internal.qux.lan
)

d=${1#*.}
h=${1%%.*}
nd=${dmap[$d]:-$d}

/usr/bin/nc -w 120 $h.$nd $2 2>/dev/null

Now, ssh server158247.quux.biz should connect you to server158247.internal.qux.lan [1]: https://man.openbsd.org/ssh_config#ProxyCommand

I figured out a working method. It's a bit ugly, but it does work. This leverages the ProxyCommand directive (see manpage) combined with a small bash helper script.

  1. Add sections like this to ~/.ssh/config — one for each domain you want remapped:
Match final host="!*.corp.foo.com,*.foo.com"
    ProxyCommand ssh_ext2int %h %p

Match final host="*.quux.biz"
    ProxyCommand ssh_ext2int %h %p
  1. Save this in your $PATH somewhere as ssh_ext2int — and chmod u+x it:
#!/usr/bin/env bash

[ $# -eq 2 ] || exit 1
typeset -A dmap
dmap=(
  [foo.com]=corp.foo.com
  [quux.biz]=internal.qux.lan
)

d=${1#*.}
h=${1%%.*}
nd=${dmap[$d]:-$d}

/usr/bin/nc -w 120 $h.$nd $2 2>/dev/null

Now, ssh server158247.quux.biz should connect you to server158247.internal.qux.lan

Source Link

I figured out a working method. It's a bit ugly, but it does work. This leverages the ProxyCommand directive (see [manpage][1]) combined with a small bash helper script.

  1. Add sections like this to ~/.ssh/config — one for each domain you want remapped:
Match final host="!*.corp.foo.com,*.foo.com"
    ProxyCommand ssh_ext2int %h %p

Match final host="*.quux.biz"
    ProxyCommand ssh_ext2int %h %p
  1. Save this in your $PATH somewhere as ssh_ext2int — and chmod u+x it:
#!/usr/bin/env bash

[ $# -eq 2 ] || exit 1
typeset -A dmap
dmap=(
  [foo.com]=corp.foo.com
  [quux.biz]=internal.qux.lan
)

d=${1#*.}
h=${1%%.*}
nd=${dmap[$d]:-$d}

/usr/bin/nc -w 120 $h.$nd $2 2>/dev/null

Now, ssh server158247.quux.biz should connect you to server158247.internal.qux.lan [1]: https://man.openbsd.org/ssh_config#ProxyCommand