50

I installed openvpn with brew. The installation went fine, no errors or missing dependencies. But now when I try to run it:

users-MBP:~ user$ brew install openvpn
Warning: openvpn-2.3.7 already installed
users-MBP:~ user$ openvpn
-bash: openvpn: command not found

I based myself on this tutorial: https://my.hostvpn.com/knowledgebase/29/OpenVPN-on-Mac-OS-X-via-Homebrew-CLI.html

Juicy
  • 715
  • Out of curiosity, why did you not choose to go with TunnelBlick? – agentroadkill Sep 02 '15 at 23:28
  • 3
    @agentroadkill After some time on Linux I have a strong preference for command-line tools over GUIs. Whenever possible I try to go for a CLI solution. – Juicy Sep 02 '15 at 23:33
  • I believe TunnelBlick is fully configurable from command line, though I rarely use it as I generally use it for simplistic end-user functions. – agentroadkill Sep 02 '15 at 23:36
  • 2
    @agentroadkill I may look into it. openvpn also has the advantage of being the same tool I used on Linux for the job so I could just copy over my configuration files, same commands etc... But I will look into TunnelBlick if I can't get it working. – Juicy Sep 02 '15 at 23:44
  • TunnelBlick is just an OpenVPN client for MacOS. Any OpenVPN config generated for Linux and/or Windows can be used with it. – agentroadkill Sep 02 '15 at 23:46
  • what is the output of which -a openvpn ? - if it's empty then you don't have the path where openvpn is installed inside your $PATH Environment Variable – konqui Jun 02 '16 at 06:10

7 Answers7

69

Add this to your ~/.bash_profile:

export PATH=$(brew --prefix openvpn)/sbin:$PATH
benweet
  • 791
28

At the terminal type:

echo $PATH 

That's your default search path for executables. Looks like the openvpn executable was installed someplace not in your search path.

First, you'll need to find the openvpn executable:

sudo find / -type f -name "openvpn" 

Then add the directory containing the openvpn executable to your default search path by adding this sort of line to the end of your .profile (in your home directory, a.k.a. /Users/yourusername/.profile:

export PATH="/some/brew/dir:$PATH"
user84215
  • 444
  • 20
    brew info openvpn is faster – igor Nov 16 '16 at 23:44
  • Try using sudo openvpn before going with this answer. It seems silly, but I was going through this answer when I found openvpn is installed in the usr/sbin folder - which means that you can't execute openvpn or anything else in that folder without sudo - and you will get openvpn: command not found without using sudo. Or you can login as root, but that's just unnecessary. Hope this helps someone else. – Devin Carpenter Feb 12 '20 at 22:00
  • Years later, the DMG/PKG installer from https://openvpn.net/vpn-client/ no longer seems to contain a command-line client. – MarkHu May 27 '21 at 17:13
17

In my case:

  1. Installation using homebrew

brew install openvpn

  1. Information regarding binaries

brew info openvpn

  1. It gave me installation path as:

/usr/local/Cellar/openvpn/2.4.0

  1. Then I browsed for bin directory but found executable inside sbin. So, I added following line

export PATH=$PATH:/usr/local/Cellar/openvpn/2.4.0/sbin

in my ~/.zshrc file as well as in ~/.bash_profile file using a text editor.

Worked Flawlessly, After a workaround for an hour :)

KeshavDulal
  • 300
  • 2
  • 7
11

You have to add /usr/local/sbin to your path.

It was installed to /usr/local/sbin but that directory is not in your $PATH by default. Add a line like this to your ~/.bashrc or equivalent:

export PATH=/usr/local/sbin:$PATH
nlsun
  • 211
  • 2
  • 2
  • 1
    This is the best fix, but the best, permanent way to make the fix it is to edit /etc/paths and add /usr/local/sbin to it (more info here) – MikeBeaton Jan 16 '19 at 09:34
2

I was having same issue today and I had to do sudo brew services start openvpn

r3b00t
  • 121
1

You can also add a symlink from usr/local/sbin into usr/local/bin like so:

cd /usr/local/bin
ln -s ../sbin/openvpn .
Landi Lark
  • 19
  • 1
1

Brew now link the openvpn binary. reinstall it using

brew reinstall openvpn