Skip to main content
added 263 characters in body
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

You can use the ProxyCommand you can setup ssh so that it will connect to a "gateway" system and then connect to a secondary system that's behind the "gateway" system.

Host internal-host
    User sam
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand ssh user@gateway nc internal-host.somedom.com %p

This technique makes use of the tool nc to act as a connector. How it works is thoroughly covered here in this article titled: Transparent Multi-hop SSH.

The other trick that I use is to add a ControlMaster to my setup so that once I'm authenticated I can "recycle" this and not have to keep re-authenticating additional connections.

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p

Lots of hosts

If you have multiple internal hosts you can use special variables that are avabile to you in your ~/.ssh/config file to pick up the hostname (%h) and port (%p).

Host host1 host2 host3
  User          internal-user
  ProxyCommand  ssh [email protected] nc %h %p

This will allow you to ssh host1 from your system and connect to host1.

References

You can use the ProxyCommand you can setup ssh so that it will connect to a "gateway" system and then connect to a secondary system that's behind the "gateway" system.

Host internal-host
    User sam
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand ssh user@gateway nc internal-host.somedom.com %p

The other trick that I use is to add a ControlMaster to my setup so that once I'm authenticated I can "recycle" this and not have to keep re-authenticating additional connections.

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p

You can use the ProxyCommand you can setup ssh so that it will connect to a "gateway" system and then connect to a secondary system that's behind the "gateway" system.

Host internal-host
    User sam
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand ssh user@gateway nc internal-host.somedom.com %p

This technique makes use of the tool nc to act as a connector. How it works is thoroughly covered here in this article titled: Transparent Multi-hop SSH.

The other trick that I use is to add a ControlMaster to my setup so that once I'm authenticated I can "recycle" this and not have to keep re-authenticating additional connections.

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p

Lots of hosts

If you have multiple internal hosts you can use special variables that are avabile to you in your ~/.ssh/config file to pick up the hostname (%h) and port (%p).

Host host1 host2 host3
  User          internal-user
  ProxyCommand  ssh [email protected] nc %h %p

This will allow you to ssh host1 from your system and connect to host1.

References

added 263 characters in body
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

You can use the ProxyCommand you can setup ssh so that it will connect to a "gateway" system and then connect to a secondary system that's behind the "gateway" system.

Host internal-host
    User sam
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand ssh user@gateway nc internal-host.somedom.com %p

The other trick that I use is to add a ControlMaster to my setup so that once I'm authenticated I can "recycle" this and not have to keep re-authenticating additional connections.

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p

You can use the ProxyCommand you can setup ssh so that it will connect to a "gateway" system and then connect to a secondary system that's behind the "gateway" system.

Host internal-host
    User sam
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand ssh user@gateway nc internal-host.somedom.com %p

You can use the ProxyCommand you can setup ssh so that it will connect to a "gateway" system and then connect to a secondary system that's behind the "gateway" system.

Host internal-host
    User sam
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand ssh user@gateway nc internal-host.somedom.com %p

The other trick that I use is to add a ControlMaster to my setup so that once I'm authenticated I can "recycle" this and not have to keep re-authenticating additional connections.

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

You can use the ProxyCommand you can setup ssh so that it will connect to a "gateway" system and then connect to a secondary system that's behind the "gateway" system.

Host internal-host
    User sam
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand ssh user@gateway nc internal-host.somedom.com %p