LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-26-2013, 02:51 AM   #1
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Rep: Reputation: 13
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
 
Old 07-26-2013, 03:18 AM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
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
would do it, ( or sudo /etc/init.d/OpenVPN )
 
1 members found this post helpful.
Old 07-26-2013, 01:15 PM   #3
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
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.
 
Old 07-26-2013, 01:53 PM   #4
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by NotAComputerGuy View Post
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.
Ahh, right ok

Well, the 'super fast' tutorial for screen in your use case
  1. ssh to your box
  2. screen
    Will diplay some help and stuff
  3. issue your VPN commnads, etc
  4. Ctrl+a , then Ctrl+d
    That detaches the screen, whatever was running is still running
  5. you are now free to exit ssh
  6. to reattach your screen session, screen -x


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.

Last edited by Firerat; 07-26-2013 at 01:54 PM. Reason: /list
 
1 members found this post helpful.
Old 07-27-2013, 05:43 AM   #5
NotAComputerGuy
Member
 
Registered: Jun 2012
Distribution: Linux Mint - Debian Edition
Posts: 349

Original Poster
Rep: Reputation: 13
Perfect!

Thank you very much!
 
Old 07-30-2013, 03:09 AM   #6
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: This week at LWN: LinuxCon: Keeping open source open LXer Syndicated Linux News 0 10-07-2009 11:30 AM
keeping xterm open? bergman Linux - Newbie 22 05-01-2009 07:24 PM
keeping the terminal window open NNP Linux - General 1 09-01-2005 11:08 PM
keeping a transparent terminal in the background adizzle Linux - Newbie 6 09-27-2004 08:44 AM
Keeping windows open martinpanda Programming 0 01-25-2002 03:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration