Keeping VPN Open Through Terminal
When I SSH into my a remote computer to use a VPN, I use the command line with OpenVPN. The question I have is I cannot use & at the end so it keeps running when I exit SSH, due to needing to enter my usename and password, so how do I keep the network connected and log out of SSH?
Thanks |
One way is to use screen
You can then disconnect ssh but the VPN should still be running re-attach to screen with screen -x ( if only one session, see its manual for full list of flags ) But I'm assuming you are logging in via ssh to start the VPN server The username/password is for what? is it to get root? You should probably start OpenVPN as a service I'd be surprised if OpenVPN didn't have a preconfigured script for this. so something like Code:
sudo service OpenVPN start |
Thanks for the response. I will look into screen. I am running OpenVPN as a user, it's just after I do the VPN command, it asks me for my VPNs username and password. That is why I can't use & at the end.
|
Quote:
Well, the 'super fast' tutorial for screen in your use case
You can have more than one screen session, think of it as multiple windows/tabs. The really handy thing with screen is the session still runs even if your ssh drops for instance, ConnectBot on Android and you loose signal. |
Perfect!
Thank you very much! |
Just another way. Probably very old school but still very nice.
Start your vpn connection but put a nohup in front of it. This makes the command immune to hangups. So when you log out the process keeps on running. Also put the & at the end to send the process into background. I know you say how do I input my user name and such. When you send the process into background with & the shell gives you a number in square brackets. This is a job number and with fg <job number> you can get the process to be shown in foreground. Now enter your credentials, suspend the job with <CTRL>+Z and have it run in the background with bg <job number>. If you are not afraid of work check the output of jobs. |
All times are GMT -5. The time now is 02:32 AM. |