13

On my Ubuntu 16.04 server, I have the OpenVPN service running as the user nobody. How can I restart the service or reload the config file for the service using, for instance, systemctl?

An openvpn process is running, but I don't know how to access it.

310 nobody    20   0   44440   3184   1968 S  0.0  0.3   1263:30 openvpn

The command su nobody does not work because no password is set. Is there an alternative?

7 Answers 7

15

Try this, I've noticed that restart doesn't work for me.

sudo systemctl stop openvpn@server
sudo systemctl enable [email protected]
sudo systemctl start openvpn@server
10

OpenVPN is a templatized service under systemd. The services are named openvpn@config.service. So you should restart your /etc/openvpn/myvpn.conf instance with:

systemctl restart openvpn@myvpn.service
1
  • The trouble is using systemctl status [email protected] doesn't reveal an active service when doing this under my login or under root user, as I assume the service is running under the nobody user
    – sumade
    Aug 20, 2017 at 22:30
5

Go to the this directory and take a look at files:

sudo su

cd /etc/systemd/system/multi-user.target.wants

ls

there should be a file in this format (could be different depend on openvpn version):

[email protected]

or

[email protected]

if you see multiple files in this format, it's because you probably use this code before:

sudo systemctl enable [email protected]

this self-made files (created by enable) does nothing and could be removed later. But for now you should find the one works well with this commands without causing any error:

sudo systemctl stop <[email protected]>
sudo systemctl start <[email protected]> 

and replace with all files in this format (starts with openvpn and ends with .service) in the directory. The one that truly stops and starts openvpn service is the file you need and others could be removed (you shouldn't have made them in first place by enabling them):

sudo rm <[email protected]>

Be careful to not to remove the one that is making the service start and stop

1

Log in as sudo su.

Run service openvpnas restart or service openvpn restart.

2
  • 1
    This actually doesn't work under Ubuntu 20.04.
    – slhck
    May 28, 2021 at 18:46
  • this works for me on ubuntu 2022
    – Eyni Kave
    Aug 11, 2022 at 20:34
0

Sometimes I found that if you're running docker on the same machine, there's some kind of conflict.

So if you're running the Docker service, I suggest you first stop Docker and then try starting OpenVPN server.

0

Another thing you can do if you don't know the exact service name or are lazy like I am. Run systemctl status openvpn* The * match up the service closest to that string. Works for the other functions like stop & start.

1
  • It does not work for me: Unit openvpn-install.sh.service could not be found.
    – Alexey Sh.
    Feb 9 at 17:53
0

For me it was [email protected], I found it in the /etc/systemd/system/multi-user.target.wants directory

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .