• Stars
    star
    2,422
  • Rank 18,205 (Top 0.4 %)
  • Language
    Perl
  • License
    GNU General Publi...
  • Created over 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Client for PPP+TLS VPN tunnel services

openfortivpn

openfortivpn is a client for PPP+SSL VPN tunnel services. It spawns a pppd process and operates the communication between the gateway and this process.

It is compatible with Fortinet VPNs.

Usage

man openfortivpn

Examples

  • Simply connect to a VPN:

    openfortivpn vpn-gateway:8443 --username=foo
  • Connect to a VPN using an authentication realm:

    openfortivpn vpn-gateway:8443 --username=foo --realm=bar
  • Store password securely with a pinentry program:

    openfortivpn vpn-gateway:8443 --username=foo --pinentry=pinentry-mac
  • Connect with a user certificate and no password:

    openfortivpn vpn-gateway:8443 --username= --password= --user-cert=cert.pem --user-key=key.pem
  • Don't set IP routes and don't add VPN nameservers to /etc/resolv.conf:

    openfortivpn vpn-gateway:8443 -u foo --no-routes --no-dns --pppd-no-peerdns
  • Using a configuration file:

    openfortivpn -c /etc/openfortivpn/my-config

    With /etc/openfortivpn/my-config containing:

    host = vpn-gateway
    port = 8443
    username = foo
    set-dns = 0
    pppd-use-peerdns = 0
    # X509 certificate sha256 sum, trust only this one!
    trusted-cert = e46d4aff08ba6914e64daa85bc6112a422fa7ce16631bff0b592a28556f993db
  • For the full list of config options, see the CONFIGURATION section of

    man openfortivpn

Smartcard

Smartcard support needs openssl pkcs engine and opensc to be installed. The pkcs11-engine from libp11 needs to be compiled with p11-kit-devel installed. Check #464 for a discussion of known issues in this area.

To make use of your smartcard put at least pkcs11: to the user-cert config or commandline option. It takes the full or a partial PKCS#11 token URI.

user-cert = pkcs11:
user-cert = pkcs11:token=someuser
user-cert = pkcs11:model=PKCS%2315%20emulated;manufacturer=piv_II;serial=012345678;token=someuser
username =
password =

In most cases user-cert = pkcs11: will do it, but if needed you can get the token-URI with p11tool --list-token-urls.

Multiple readers are currently not supported.

Smartcard support has been tested with Yubikey under Linux, but other PIV enabled smartcards may work too. On Mac OS X Mojave it is known that the pkcs engine-by-id is not found.

Installing

Installing existing packages

Some Linux distributions provide openfortivpn packages:

On macOS both Homebrew and MacPorts provide an openfortivpn package. Either install Homebrew then install openfortivpn:

# Install 'Homebrew'
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# Install 'openfortivpn'
brew install openfortivpn

or install MacPorts then install openfortivpn:

# Install 'openfortivpn'
sudo port install openfortivpn

A more complete overview can be obtained from repology.

Building and installing from source

For other distros, you'll need to build and install from source:

  1. Install build dependencies.

    • RHEL/CentOS/Fedora: gcc automake autoconf openssl-devel make pkg-config
    • Debian/Ubuntu: gcc automake autoconf libssl-dev make pkg-config
    • Arch Linux: gcc automake autoconf openssl pkg-config
    • Gentoo Linux: net-dialup/ppp pkg-config
    • openSUSE: gcc automake autoconf libopenssl-devel pkg-config
    • macOS (Homebrew): automake autoconf [email protected] pkg-config
    • FreeBSD: automake autoconf libressl pkgconf

    On Linux, if you manage your kernel yourself, ensure to compile those modules:

    CONFIG_PPP=m
    CONFIG_PPP_ASYNC=m
    

    On macOS, install 'Homebrew' to install the build dependencies:

    # Install 'Homebrew'
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
    # Install Dependencies
    brew install automake autoconf [email protected] pkg-config
    
    # You may need to make this openssl available to compilers and pkg-config
    export LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS"
    export CPPFLAGS="-I/usr/local/opt/openssl/include $CPPFLAGS"
    export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH"
  2. Build and install.

    ./autogen.sh
    ./configure --prefix=/usr/local --sysconfdir=/etc
    make
    sudo make install

    If you need to specify the openssl location you can set the $PKG_CONFIG_PATH environment variable. For fine-tuning check the available configure arguments with ./configure --help especially when you are cross compiling.

    Finally, install runtime dependency ppp or pppd.

Running as root?

openfortivpn needs elevated privileges at three steps during tunnel set up:

  • when spawning a /usr/sbin/pppd process;
  • when setting IP routes through VPN (when the tunnel is up);
  • when adding nameservers to /etc/resolv.conf (when the tunnel is up).

For these reasons, you need to use sudo openfortivpn. If you need it to be usable by non-sudoer users, you might consider adding an entry in /etc/sudoers or a file under /etc/sudoers.d.

For example:

visudo -f /etc/sudoers.d/openfortivpn
Cmnd_Alias  OPENFORTIVPN = /usr/bin/openfortivpn

%adm       ALL = (ALL) OPENFORTIVPN

Adapt the above example by changing the openfortivpn path or choosing a group different from adm - such as a dedicated openfortivpn group.

Warning: Make sure only trusted users can run openfortivpn as root! As described in #54, a malicious user could use --pppd-plugin and --pppd-log options to divert the program's behaviour.

SSO/SAML/2FA

In some cases, the server may require the VPN client to load and interact with a web page containing JavaScript. Depending on the complexity of the web page, interpreting the web page might be beyond the reach of a command line program such as openfortivpn.

In such cases, you may use an external program spawning a full-fledged web browser such as openfortivpn-webview to authenticate and retrieve a session cookie. This cookie can be fed to openfortivpn using option --cookie-on-stdin. Obviously, such a solution requires a graphic session.

Contributing

Feel free to make pull requests!

C coding style should follow the Linux kernel coding style.

More Repositories

1

yamllint

A linter for YAML files.
Python
2,696
star
2

PhotoCollage

Graphical tool to make photo collage posters
Python
374
star
3

localstripe

A fake but stateful Stripe server that you can run locally, for testing purposes.
Python
185
star
4

familytreemaker

Generates a family tree graph from a simple text file
Python
179
star
5

kijijiapi

Robot to post ads on Kijiji
Python
65
star
6

gnome-magic-window

Bind a key to a specific program in Gnome Shell.
JavaScript
26
star
7

coucharchive

Create and restore backups of a whole CouchDB server, with simple tar.gz files
Python
13
star
8

copr-couchdb

Unofficial CouchDB 3 RPM packages for Fedora and EPEL
Shell
9
star
9

arm-analyser

ARM binaries analyser
C
7
star
10

copr-some-nice-fonts

Some nice fonts including Arial, Courier New, Helvetica, etc. for Fedora and CentOS
6
star
11

vim-python-logging

Vim plugin to color logs generated by python-logging
Vim Script
4
star
12

keyboard-stickers

Localize your keyboard!
Python
4
star
13

rhythmbox_playlist_to_m3u

Converts playlists stored by Rhythmbox to M3U files
Python
3
star
14

posix-read

Do POSIX read on files and sockets with Node.js
C++
3
star
15

dotfiles

Shell
3
star
16

libcoresightomap4430

Use STM and ETB hardware tracing modules on OMAP4430 SoC
C
2
star
17

mousemode

C
2
star
18

nest-css

Script to nest all rules of a CSS document inside an arbitrary selector
Python
1
star
19

copr-oauth2_proxy

Fedora & CentOS packages for oauth2_proxy (previously Google Auth Proxy)
1
star
20

context_unnester

Fixes Python source code that use contextlib.nested.
Python
1
star
21

copr-python37

Unofficial Python 3.7 packages for CentOS 7
1
star
22

textree

Jade-like syntax processor that allows easy writing of HTML or XML files with auto-templating and Javascript-based scripting features
JavaScript
1
star
23

find-duplicate-images

Search similar images in a list of files or directories
Python
1
star