OpenVPN / openvpn3-linux

OpenVPN 3 Linux client
GNU Affero General Public License v3.0
563 stars 151 forks source link

Can't add key or repo when installing - permission denied #104

Closed Ethanol6 closed 2 years ago

Ethanol6 commented 2 years ago

Following the instructions from the page here: https://community.openvpn.net/openvpn/wiki/OpenVPN3Linux?__cf_chl_tk=ajlvFAXYUXQhSTV.WuU0ProEIUknNRiWEEz8MXvGKLA-1643821240-0-gaNycGzNBr0

The first step fails saying "permission denied" curl -fsSL https://swupdate.openvpn.net/repos/openvpn-repo-pkg-key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/openvpn-repo-pkg-keyring.gpg

I'm using Linux Mint 20.2

schwabe commented 2 years ago

you need to have root rights to write into /etc/. Try running sudo -s first.

Ethanol6 commented 2 years ago

I should have mentioned that I did run it with sudo. Would -s make any difference?

dsommers commented 2 years ago

Does the "permission denied" come from curl when fetching the file ... or when writing the openvpn-repo-pkg-keyring.gpg file?

We are only able to to look into issues with the former, not the latter. The -s argument may have an effect for you.

schwabe commented 2 years ago

sudo -s gives you a shell. As @dsommers said just putting sudo in front here will not work as you will need to ensure that the ">" part is actually done with sudo right and not the commands that are being run. So getting a root shell with sudo -s is here the easiest way.

curl -fsSL https://swupdate.openvpn.net/repos/openvpn-repo-pkg-key.pub | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/openvpn-repo-pkg-keyring.gpg

would work here

Ethanol6 commented 2 years ago

The error is not with curl but writing the file. Ok, are sudo -s and sudo su the same? Either just give me the root user prompt. It works with either but I never run anything as root, why is this different? And if I were on a system with root account disabled would this even be possible?

I can run this as root just fine. Then using my user account I can sudo rm openvpn* and delete the file just fine. Not sure why I have the permission to delete it but not to write it.

Ethanol6 commented 2 years ago

sudo -s gives you a shell. As @dsommers said just putting sudo in front here will not work as you will need to ensure that the ">" part is actually done with sudo right and not the commands that are being run. So getting a root shell with sudo -s is here the easiest way.

curl -fsSL https://swupdate.openvpn.net/repos/openvpn-repo-pkg-key.pub | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/openvpn-repo-pkg-keyring.gpg

would work here

This works as well. It prints out a bunch of junk to standard output but I only need to use sudo with this one.

moezbenrebah commented 1 year ago

I have the same issue I ran into the permission denied error, either with sudo or sudo -s:

sudo -s curl -fsSL https://swupdate.openvpn.net/repos/openvpn-repo-pkg-key.pub | sudo gpg --dearmor > /etc/apt/trusted.gpg.d/openvpn-repo-pkg-keyring.gpg
bash: /etc/apt/trusted.gpg.d/openvpn-repo-pkg-keyring.gpg: Permission denied
curl: (23) Failed writing body

please help me

dsommers commented 1 year ago

@moezbenrebah Read this comment very carefully: https://github.com/OpenVPN/openvpn3-linux/issues/104#issuecomment-1028244157