184 | | 2. If the above option does not work then you can try using [https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding ssh port forwarding] to get to your host. The main idea is that you will forward a local port on the client to go through the connection to <pub_host> and from there to ssh to <priv_host>. If you want to do this in command line then : |
185 | | {{{ |
186 | | |
187 | | }}} |
188 | | }}} |
| 184 | 2. If the above option does not work then you can try using [https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding ssh port forwarding] to get to your host. The main idea is that you will forward a local port on the client to go through the connection to <pub_host> and from there to ssh to <priv_host>. If you want to do this in command line then first login to the public host: |
| 185 | {{{ |
| 186 | ssh -L <local port>:<priv_host>:22 <username>@<pub_host> |
| 187 | }}} |
| 188 | |
| 189 | Then on a different terminal, try logging to the private host through the local port : |
| 190 | {{{ |
| 191 | ssh -i <private key> <username>@localhost -p <local port> |
| 192 | }}} |
| 193 | |
| 194 | You can also modify the ssh configuration file to that effect. This way it is easier to port-forward multiple firewalled hosts by adding the following lines in the file : |
| 195 | {{{ |
| 196 | Host <pub_host_alias> |
| 197 | Hostname <pub_host> |
| 198 | LocalForward <local port1> <priv_host_1>:22 |
| 199 | LocalForward <local port2> <priv_host_2>:22 |
| 200 | user <username> |
| 201 | |
| 202 | Host <priv_host_alias_1> |
| 203 | Hostname localhost |
| 204 | port <local port1> |
| 205 | user <username> |
| 206 | |
| 207 | Host <priv_host_alias_2> |
| 208 | Hostname localhost |
| 209 | port <local port2> |
| 210 | user <username> |
| 211 | }}} |
| 212 | Then on one terminal do : |
| 213 | {{{ |
| 214 | ssh <pub_host_alias> |
| 215 | }}} |
| 216 | |
| 217 | And on another terminal: |
| 218 | {{{ |
| 219 | ssh <priv_host_alias_1> |
| 220 | }}} |