0

I've set up port forwarding over ssh so I can securely connect to a web console. Since the bash command is pretty long, I want to create a small script that will do the following;

  • Check if there is an open ssh connection to the server in question.
  • If it's not open, open it.
  • Open browser to the console I want to access.

This is what I have so far

#!/bin/sh ssh -N -l my_username -i ~/.ssh/id_rsa_ssh -L <port>:<ip>:<port> <forwarding_ip> > /dev/null 2>&1 < /dev/null & open -a Firefox http://localhost:<port>/url/to/something/secure 

The ssh connection opens, but the browser can't establish a connection. Is there any way to programmatically open an ssh connection, background it, and ensure it stays open?

0

1 Answer 1

2

You wanted autossh.

autossh - Automatically restart SSH sessions and tunnels

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.