You are not logged in.
Pages: 1
Currently, I have to open terminal up and execute something like this to hook up to the VPN:
$ cd /etc/openvpn/ ; sudo openvpn --config foo.ovp
It doesn't work within NetworkManager applet, so I need to write a small GUI to make that
easy for those people not familiar with working in terminal. What may complicate things
is the fact this command asks for username and password in terminal, and then connects.
I want to be able to enter login and password in GUI, and to have notification in GUI when connected.
Maybe some kinda small python/wxgtk script or something like that. Can you help me?
Offline
I'm on a Tcl kick, and this problem is what Tcl was made for. Unfortunately I'm not much at Tk so if you want it to look different, that's up to you. I just copied from http://www.tkdocs.com/tutorial/firstexample.html.
The below script prompts for a username and password, then feeds the password to sudo. If you have more challenge-response going on, as I assume you probably do (since sudo doesn't ask for a password), you'll need to add more "expect ..." and "exp_send ..." lines to represent what the program is asking you and what you want to send it. I've flagged the relevant spot in the code with "EXTRA STUFF GOES HERE".
I haven't gone the notification route yet because there's too much unknown. Does the openvpn program exit when it's connected, or does it print a message and stay open until the VPN is closed? (With very little research you could do the Expect scripting yourself; it's quite a simple language. GUIs are more complicated but Tk is a breeze compared to most.)
#!/usr/bin/wish
package require Expect
cd /etc/openvpn
wm title . "Connect to VPN"
grid [ttk::frame .content] -column 0 -row 0 -sticky nwes
grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1
grid [ttk::label .content.ulbl -text "Username"] -column 0 -row 0
grid [ttk::label .content.plbl -text "Password"] -column 0 -row 1
grid [ttk::entry .content.user -textvar username] -column 1 -row 0
grid [ttk::entry .content.pass -textvar password -show "*"] -column 1 -row 1
grid [ttk::button .content.conn -text "Connect" -command connect] -column 1 -row 2
foreach w [winfo children .content] {
grid configure $w -padx 5 -pady 5
}
focus .content.user
bind . <Return> connect
proc connect {} {
spawn sudo openvpn --config foo.ovp
expect ":"
exp_send "$::password\r"
# EXTRA STUFF GOES HERE
expect eof
exit
}
Offline
Thanks! But, I am getting this error when trying to execute the script:
Error in startup script: can't find package Expect
while executing
"package require Expect"
(file "./pia" line 2)
Offline
It doesn't work within NetworkManager applet
Are you using the plugin?
Offline
I'm using regular nm-applet after Network setting configuration, except nm-applet i don't see any other application, I have this installed:
[luther@localhost ~]$ sudo pacman -Ss networkmanager-openvpn
[sudo] password for luther:
extra/networkmanager-openvpn 0.9.8.4-1 [installed]
NetworkManager VPN plugin for OpenVPN
It just keep "connecting" and then after 30 secs refuses, with no warning at all.
Offline
Thanks! But, I am getting this error when trying to execute the script
Sorry, I should have mentioned you need Expect installed. (You have Tcl and Tk installed already, as lots of things depend on them.) It's a small library.
pacman -S expect
Offline
Pages: 1