View previous topic :: View next topic |
Author |
Message |
MALDATA n00b
Joined: 07 Apr 2011 Posts: 53
|
Posted: Sat Apr 09, 2022 9:03 pm Post subject: openvpn behaves differently with & without sudo |
|
|
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 |
|
|
mike155 Advocate
Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Sat Apr 09, 2022 10:27 pm Post subject: |
|
|
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
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)
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 |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3879
|
Posted: Sat Apr 09, 2022 10:34 pm Post subject: |
|
|
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
_________________
|
|
Back to top |
|
|
MALDATA n00b
Joined: 07 Apr 2011 Posts: 53
|
Posted: Sat Apr 09, 2022 11:01 pm Post subject: |
|
|
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...
Thanks for getting me sorted out. |
|
Back to top |
|
|
|