jotyGill / openpyn-nordvpn

Easily connect to and switch between, OpenVPN servers hosted by NordVPN on Linux (+patch leakes)
GNU General Public License v3.0
628 stars 114 forks source link

Question about installation #160

Open Jorman opened 6 years ago

Jorman commented 6 years ago

Hi, I just discovered this script and I think is quite good for my purpose, seems very good script!

I'm on a qnap system and qnap offer only qvpn service, an application where I've to load the openvpn profile and manually connect to it, so I've always to check if the connection are good and don't "risk" to use my ip.

So my "hope" is to make it automatic, like I give to the script my nordvpn credential, then the script connect to the vpn and if the connection go down, switch to another server.

I think that is pretty much the function that the script do, but I've 2 questions

  1. There's any plan or any way to "select" which service go over the vpn?

  2. Anyone have installed this on a Qnap system? Is based on entware and I've this available

    opkg list | grep openvpn
    collectd-mod-openvpn - 5.8.0-5 - OpenVPN traffic/compression input plugin
    openvpn-easy-rsa - 3.0.1-1 - CLI utility to build and manage a PKI CA.
    openvpn-nossl - 2.4.5-3 - Open source VPN solution using plaintext (no SSL)
    openvpn-openssl - 2.4.5-3 - Open source VPN solution using OpenSSL

Jo

Jorman commented 6 years ago

Tried to install, works!

Tried to configure, don't

sudo: unknown user: root
sudo: unable to initialize policy plugin
Traceback (most recent call last):
  File "/opt/bin/openpyn", line 11, in <module>
    load_entry_point('openpyn==2.6.0', 'console_scripts', 'openpyn')()
  File "/opt/lib/python3.6/site-packages/openpyn/openpyn.py", line 130, in main
    args.skip_dns_patch, args.silent, args.nvram, args.openvpn_options)
  File "/opt/lib/python3.6/site-packages/openpyn/openpyn.py", line 165, in run
    initialise()
  File "/opt/lib/python3.6/site-packages/openpyn/openpyn.py", line 349, in initialise
    credentials.save_credentials()
  File "/opt/lib/python3.6/site-packages/openpyn/credentials.py", line 32, in save_credentials
    subprocess.check_call(["sudo", "chmod", "600", credentials_file_path])
  File "/subprocess.py", line 291, in check_call
subprocess.CalledProcessError: Command '['sudo', 'chmod', '600', '/opt/lib/python3.6/site-packages/openpyn/credentials']' returned non-zero exit status 1.

Any idea?

jotyGill commented 6 years ago

Hi Jo,

Thanks.

1 There's any plan or any way to "select" which service go over the vpn? Ans: Not within openpyn But check out https://github.com/mrahmadt/SmartGW

2: no idea mate.

In this case, you can't seem to run commands as sudo command as your system doesn't have user 'root' in it. maybe create a user called root and give it root permissions. openpyn uses a lot of commands as sudo command to gain root access for changing iptables, running openvpn, etc.. I can't just have the script run as root cause that way you can't have desktop notifications. that's the way things are unfortunately.

Jorman commented 6 years ago

Thanks I'll look into it!

Not possible to implement some flag, like the one for asus, to skip this command as sudo? So maybe you can handle with one or more flag this situation and the one for entware systems, this one https://github.com/jotyGill/openpyn-nordvpn/issues/168#issuecomment-417552572

What do you think?

jotyGill commented 6 years ago

would have been easy if it was a few commands. throughout the program there would be >50 commands being run as sudo. I'll see what I can do

Jorman commented 6 years ago

Wow! A lot of commands.

I don't know if simply installing sudo and run the program like root can be enough

jotyGill commented 6 years ago

Most of them are for the '-f' switch anyway. give it a go.

xmflsct commented 5 years ago

Same problem here on asus-merlin.. Cannot even run init and add a credential file as it says there is no root user. How can I do?

1951FDG commented 5 years ago

@xmflsct Have you followed instructions as outlined in README

# common dependencies
opkg install git git-http iputils-ping procps-ng-pgrep python3 python3-pip sudo unzip wget
cd /tmp/share/
git clone https://github.com/jotyGill/openpyn-nordvpn.git
cd openpyn-nordvpn/
git pull
pip3 install --upgrade setuptools
pip3 install --upgrade .
xmflsct commented 5 years ago

@1951FDG Yes, installation is completed, and I can run openpyn -h without problem. When I run openpyn --init after I typed in my username and password, it terminated saying that there is no root user in sudoers. I can see that credential file has been generated. It seems like asus-merlin does not allow to have a user named root.

salvq commented 2 years ago

@xmflsct have you been able to run openpyn --init ? I currently stuck on the below error on Asus merlin, installation all OK.

Enter the password for NordVPN:
sudo: unknown user: root
sudo: unable to initialize policy plugin
Traceback (most recent call last):
  File "/opt/bin/openpyn", line 33, in <module>
    sys.exit(load_entry_point('openpyn==2.7.5', 'console_scripts', 'openpyn')())
  File "/opt/lib/python3.9/site-packages/openpyn/openpyn.py", line 138, in main
    return_code = run(
  File "/opt/lib/python3.9/site-packages/openpyn/openpyn.py", line 156, in run
    initialise(log_folder)
  File "/opt/lib/python3.9/site-packages/openpyn/openpyn.py", line 442, in initialise
    credentials.save_credentials()
  File "/opt/lib/python3.9/site-packages/openpyn/credentials.py", line 42, in save_credentials
    subprocess.check_call(["sudo", "chmod", "600", credentials_file_path])
  File "/opt/lib/python3.9/subprocess.py", line 373, in check_call
subprocess.CalledProcessError: Command '['sudo', 'chmod', '600', '/opt/lib/python3.9/site-packages/openpyn/credentials']' returned non-zero exit status 1.

Thanks for help

xmflsct commented 2 years ago

@salvq sorry I am not using this library anymore.

salvq commented 2 years ago

@salvq sorry I am not using this library anymore.

I see, have you found some alternative for asus merlin ?

Thanks

xmflsct commented 2 years ago

@salvq Nope. I was using mannual OpenVPN settings for a while before switching to running NordVPN on my Raspberry Pi.

1951FDG commented 2 years ago

@salvq

I'm the maintainer for the Asus Merlin part of the code

A change was made in the latest test branch to address the fact that some systems don't have a user named root: https://github.com/jotyGill/openpyn-nordvpn/commit/f0bd26a5fd8d70bc51423c13bf46ed9adee436d8#diff-a925c95e804261d8dcf5a2768740fe03e3c9de4edd0d3acbc111d88cf91013fd

Allow admin user to run sudo

sed -i 's~root ALL=(ALL) ALL~admin ALL=(ALL) ALL~g' /opt/etc/sudoers

Install the test branch

cd /tmp/share/
git clone --branch test https://github.com/jotyGill/openpyn-nordvpn.git
cd openpyn-nordvpn/
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade .

Always also refer to the readme of the test branch, which is the most up to date readme: https://github.com/jotyGill/openpyn-nordvpn/blob/test/README.md

salvq commented 2 years ago

Thanks for the help