Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
openvpn behaves differently with & without sudo
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
MALDATA
n00b
n00b


Joined: 07 Apr 2011
Posts: 53

PostPosted: Sat Apr 09, 2022 9:03 pm    Post subject: openvpn behaves differently with & without sudo Reply with quote

I don't know a whole lot about openvpn, so maybe this is an easy one. I have an openvpn file from my VPN provider. If I log in as root, I can do
Code:
openvpn --config /path/to/my/openvpn_file.ovpn
and it will prompt me to "Enter Auth Username" and "Enter Auth Password" as expected. I add the credentials from my VPN provider, and it connects as expected.

If I do the exact same thing, only as a normal user with sudo, i.e.,
Code:
sudo openvpn --config /path/to/my/openvpn_file.ovpn


it behaves differently. Instead of prompting with "Enter Auth Username" and "Enter Auth Password" it just prompts "Password:" and fails to connect.

When I try to connect on a different system (running Arch Linux), connecting with sudo works perfectly fine.

Can anyone explain why this would happen and how I can make it work with sudo?

Thanks!
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Sat Apr 09, 2022 10:27 pm    Post subject: Reply with quote

sudo is tricky.

The prompt "Password:" probably means that you should enter your own password (not the root password). It seems that you have not configured sudo to allow 'sudo [-u root] <command>' without asking for a password.

You could run visudo (as root) and configure sudo to allow running 'sudo openvpn' from your user without asking for a password.

Furthermore, 'sudo [-u root] <command>' differs from running '<command>' as user root. The environment in which '<command>' is executed is still the environment of your user, not the environment of root. Try
Code:
sudo pwd

for example. It will not show '/root', but the directory in which you were when you issued sudo.

You could try option -i (or --login)
Code:
sudo -i pwd

That will return '/root'.

If 'sudo openvpn' doesn't work after you you have solved the password problem, you could try 'sudo -i openvpn'.


Last edited by mike155 on Sat Apr 09, 2022 10:35 pm; edited 1 time in total
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Sat Apr 09, 2022 10:34 pm    Post subject: Reply with quote

Quote:

it behaves differently. Instead of prompting with "Enter Auth Username" and "Enter Auth Password" it just prompts "Password:" and fails to connect.


This refers to sudo password.
Is your user sudo-allowed?
Try
Code:

echo "<username> ALL=(ALL:ALL) ALL" | sudo tee /etc/sudoers.d/<username>

Also you dont need to manually give credentials.
in the .ovpn file include
Code:

auth-user-pass /path/to/creds/file

and create the said file like
Code:

username
password

_________________
:)
Back to top
View user's profile Send private message
MALDATA
n00b
n00b


Joined: 07 Apr 2011
Posts: 53

PostPosted: Sat Apr 09, 2022 11:01 pm    Post subject: Reply with quote

Oof. A while back I changed the sudo configuration so it doesn't have the usual 15-minute grace period and I totally forgot I did that. So, yeah... it just wanted my sudo password.

I'm not usually an emoji guy, but... :oops:

Thanks for getting me sorted out.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum