SSH tunnel

Start a tunnel to proxy through a remote host to an inaccessible server behind remote host. For example to access a server on a cloud private network.
A local port will be listening for connections which will be proxied through the remote bastion/jump box.
It's also possible to create a ssh tunnel reverse proxy from the bastion/jump to a local machine. This is useful for bridging into a corporate VPN. 
The following is the former.

copy private key to ~/.ssh

lower access privileges: 

chmod 400 ~/.ssh/somekey

start agent if not running: 
eval `ssh-agent`

add keys: 
ssh-add ~/.ssh/somekey

add node to known_hosts
ssh-keygen -f "/home/username/.ssh/known_hosts -R somehostname

start tunnel
Will connect remotely an listen on local port.
The first port below is the local port listening, the second port is the port on the remote host on which to connect.
ssh -L 9222:someRemotHost:9200 ubuntu@someRemoteBastionJumpBox

Alternative
Does not require adding key since it's specified arg to ssh
ssh -i ~/.ssh/someKey -L 9222:someRemoteHost:9200 ubuntu@someRemoteBastionJumpBox

Comments

Popular posts from this blog

Sites, Newsletters, and Blogs

Oracle JDBC ReadTimeout QueryTimeout