I want to run openvpn every time I log on, but currently I run

sudo openvpn --config <myconfig> --auth-user-pass <user/pass>

every time. Is there a way to make it run that automatically and not need my password?

I could make it launch a terminal and run a script but is there a way that would not require me to type my password every time? Can I maybe give myself permissions to whatever openvpn needs so it doesn’t need sudo? How do I find out what those permissions are? Is this the right place to ask?

I’m running KDE/Plasma 6 on Manjaro should that matter

edit: Thanks all! I’m going to try the systemd option, if I can’t get that working I’ll fall back to the cronjob option, and failing that changing openvpn to not need a password for sudo and launching a script at kde statup.

  • Supermariofan67@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    7 months ago

    For this in particular, look into setting up NetworkManager to do the openvpn configuration, it has that functionality built in. Otherwise, systemd unit file

    • just some guy@sh.itjust.works
      link
      fedilink
      arrow-up
      2
      ·
      7 months ago

      I don’t use open VPN so I don’t know for sure, but I think you’re right as the best way to go. Pretty sure I recall Network Manager having an option to set a vpn to be always on when a network connection is made and an option to save credentials.