posted ago by RightSideFunding ago by RightSideFunding +5 / -0

Right now I have to

ssh -L 9999:localhost:6379 ServerName

But , how can I make this standard, all the time?

Thanks, if any one knows

Comments (10)
sorted by:
kung-flu-fighting 4 points ago +4 / -0

turn it into a daemon!

RightSideFunding [S] 1 point ago +1 / -0

with systemd?

ambientenergy102 1 point ago +1 / -0

Depending on your linux distro you could try putting your commands in the init.rc file. If its just simple stuff, having the init file execute a shell script that you can easily edit is a good place to put basic commands if you don't want to write a full service

Corianas 3 points ago +3 / -0

I used a tutorial to do it 2 days ago:

Give this a follow, and good luck.

If it works, it will start automatically, and if it crashes it will reboot the program so it runs again.

603win 2 points ago +2 / -0

If I find myself doing that, I usually make it an SSH config. Actually, most switches and options I regularly pass to SSH I try to put in there. My ideal UX is “ssh <somewhere>” and it just figures it out. For your example, this would look like:

Host ServerName

   LocalForward 9999 localhost:6379

Now you can ssh -fNT ServerName (flags are: run in background, don’t execute any command, don’t allocate a TTY) either on a shell manually or in a systemd unit.

RightSideFunding [S] 1 point ago +1 / -0

Very interesting, thank you!

I learned about config files a while back, and it is a very useful and easy method.

I will look into this further

Torrvarpen 1 point ago +1 / -0

Some people love systemd, others hate it. Ubuntu already have it by default so it's probably the easiest to use. You could also use a cronjob. Type:

crontab -e

then enter:

@reboot ssh -L 9999:localhost:6379 ServerName > /dev/null 2>&1

This will run the script in the background on every boot.

RightSideFunding [S] 2 points ago +2 / -0

Yeah.. I was thinking that a cronjob might be the best short-term direction. systemd does seem like a more reliable solution, and probably more appropriate, but I don't know it, and I don't know if I want to learn it.

I was also considering the docker restart option, or there might be a restart option with nginx, or gunicorn.

thanks !

Torrvarpen 3 points ago +3 / -0

In Ubuntu, nginx comes with systemd by default:

(sudo) systemctl restart|start|stop|status nginx

Which makes it a suitable and reliable choice for reverse proxy too. Cronjob is simple, but not super reliable. Systemd from scratch requires a 10+ line config file to be written and put in a certain folder (multiple locations available), then enabled and started.

It's not too hard, but can be a bit tricky. Especially if it's just for one single command. If you know how to configure nginx as a reverse proxy and have it installed I think that might be your most reliable and easiest choice tho.

Hillarys_Ballsack 1 point ago +1 / -0

Alternative: put both machines on the same VPN and start the clients on boot. SSH or TCP (HTTP etc) via the VPN IP.