Openvpn client linux console

Command Line Functionality for OpenVPN Connect

We introduced support for the command-line interface (CLI) in OpenVPN Connect version 3.3 for Microsoft Windows and macOS. Using a console on a supported operating system, you can use the CLI to manage most application functions. This document provides an overview of the commands you can use.

Get Started

Locate OpenVPN Connect binary:

Helpers

These commands won’t launch the application, but are useful for gathering information from the terminal output.

Commands available

List all of the available commands with a short description.

—accept-gdpr — Accept GDPR for application usage —hide-tray — Launch the application and hide tray icon —minimize — Launch app in the background and UI window does not display —quit — Quit the application —list-settings — Show all application’s setting values —set-setting — Change any application setting Format: —set-setting= —value= Setting values (values in [] are default options): vpn-protocol: [adaptive]|udp|tcp timeout: 0,10,30,[60],120 launch-options: none|connect-latest|[start-app]|restore-connection seamless-tunnel: true|[false] shortcut-minimize: [true]|false captive-portal-detection: [true]|false software-update: never|[daily]|weekly|monthly theme: [system]|default|dark tray-icon-style: [monochrome]|colorful enable-crash-reporting: true|[false] min-tls-version: [default]|tls-1-0|tls-1-1|tls-1-2|tls-1-3 ipv6: [default]|no|yes compression: [no]|yes|asym google-dns-fallback: [true]|false —skip-startup-dialogs — Close (skip) information dialogs that OpenVPN Connect shows during the first launch (onboarding tour, update changes, etc.) —version — Show the application version —list-profiles — Show list of profiles imported in the application —import-profile — Import profile by path to a file. All parameters except path are optional and will be saved in the profile configuration Format: —import-profile= —name= —username= —password= —pkp= certificate= —remove-profile — Remove profile by ID or profile name. ID has a higher priority Format: —remove-profile= —list-certificates — Show list of certificates imported into the application —import-certificate — Import PKCS12 certificate/key pair (.p12) into the application. Password parameter is optional Format: —import-certificate= —password= —remove-certificate — Remove certificate from the application storage Format: —remove-certificate=

App version

Displays the application version and build number.

Читайте также:  Безопасность операционной системы специального назначения astra linux special edition буренин

Launch flags

These commands can launch OpenVPN Connect if it is not running, or can be executed on the running instance. They can be used together, in any order.

Launch in background

Launches the app in the background. The UI window won’t open.

Hide tray icon

Launches the application and hides the tray icon.

Configuration

Notifications

Accepts the General Data Protection (GDPR) consent. Note: After installation, if you start the application without this flag and haven’t previously accepted GDPR through the UI, the Connect app won’t function and won’t accept commands. Instead, you will receive an error message.

Skip startup dialogs

Closes and dismisses the information dialogs that display at first launch of OpenVPN Connect. These dialogs include the onboarding tour and the list of recent changes. The next time the application UI launches, these dialogs won’t display. Note: This flag doesn’t skip the GDPR dialog.

Profiles

List all profiles

Displays the list of profiles that are imported into OpenVPN Connect. The information includes profile ID, profile name, hostname, type, username, and server override.

[< id: , name: , host: , type: , username: , server-override: >, . ]

Import a profile

—import-profile= —name= —username= —password= —pkp= certificate=

Imports a profile from a file location, with the file path as a required parameter. All other parameters are optional, but if provided they are saved in the profile configuration. For example, a password can be used during connection for the specific profile. Also, you can pass these parameters in the UI for each connection.

If the import is successful, the command outputs the profile information.

< "message": < "id": "", "name": "", "host": "", "type": "", "username": "", "server-override": "" >, "status": "success" >

If unsuccessful, the command outputs an error message.

Remove a profile

Removes a profile using either the profile ID or profile name. The command line outputs either a success or error status message.

Certificates Management

List all certificates

Displays the list of imported certificates. The output includes the cert ID, hash, expiration state, and a subject summary.

[< cert-id: , hash: , is-expired: true|false, subject-summary: >, . ]

Import a certificate

—import-certificate= —password=

Imports the PKCS 12 certificate/key pair from a file location. The certificate saves in OS Certificate Storage or keychain. The file path is required, but the password is optional. The command output displays the cert ID, hash, expiration state, and a subject summary.

< "message": < "cert-id": , "hash": , "is-expired": true|false, "subject-summary": >, "status": "success" >

If the import fails, the command output displays an error message.

Remove a certificate

Removes a certificate by cert ID. The command line outputs either a success or error status message.

Settings Management

List all application setting values

Lists all of the application setting values, including protocol, timeout, launch options, seamless tunnel, and others.

Set a setting value

Changes any of the application settings. The command line outputs either a success or error status message.

Updates & Announcements

Cyber Shield Released

Cyber Shield protects you from cyber threats without requiring you to tunnel internet traffic. Turn Shield ON.

Release Notes 2.12.0

Access Server 2.12.0 comes with support for Data Channel Offload, a kernel accelerated method of encrypting/decrypting VPN traffic. It also allows setting unique global group subnets so routing in clustering mode is possible. Aside from this numerous fixes and improvements are included.

Access Server

Our popular self-hosted solution. Comes with two free connections. No credit card required.

CloudConnexa™

Cloud-delivered, as-a-service solution. Comes with three free connections. No credit card required.

OpenVPN is a leading global private networking and cybersecurity company that allows organizations to truly safeguard their assets in a dynamic, cost effective, and scalable way.

© Copyright 2023 OpenVPN | OpenVPN is a registered trademark of OpenVPN, Inc. |
CloudConnexa is a trademark of OpenVPN, Inc.

Источник

Управление VPN подключениями из консоли Linux

В этой статье мы рассмотрим, как создать VPN подключение из консоли Linux и подключиться к удаленному VPN серверу из CLI. Отдельно рассмотрим, как создать L2TP и PPTP VPN подключения.

Как создать L2TP VPN подключение в Linux?

Вы можете использовать NetworkManager для создания VPN подключений L2TP из консоли Linux.

Для установки NetworkManager с поддержкой L2TP выполните команду:

  • В CentOS/RHEL/Fedora: # yum -y install NetworkManager-l2tp
  • Для установки в Ubuntu/Debian, нужно сначала добавить репозиторий:
    $ sudo add-apt-repository ppa:nm-l2tp/network-manager-l2tp
    $ sudo apt-get install network-manager-l2tp

установка network-manager-l2tp в linux

Для создания нового VPN подключения L2TP используется команда:

$ nmcli connection add connection.id [VPNConnectionName] con-name [VPNConnectionName] type VPN vpn-type l2tp ifname — connection.autoconnect no ipv4.method auto vpn.data «gateway = [ipv4], ipsec-enabled = yes, ipsec-psk = 0s»$(base64

  • [VPNConnectionName] — имя VPN соединения
  • [ipv4] — ip адрес VPN сервера L2TP/IPSEC
  • [PSK] — ключ PSK (Pre Shared Key)
  • [user] — имя пользователя VPN
  • [user-password] — пароль

Настройки нового VPN подключения сохраняются в файл /etc/NetworkManager/system-connections/.

Вывести все подключения в NetworkManager:

Показать информацию о созданном VPN подключении:

$ nmcli c show id [VPNConnectionName]

Для Для подключения к VPN серверу из командной строки:к VPN серверу их командной строки:

$ nmcli c up [VPNConnectionName]

При подключении к удаленному VPN серверу может появится ошибка:

Error: Connection activation failed: Could not find source connection.
  • Проверьте логи journactl
  • Для физического интерфейса (например, ens33 ) задан шлюз по-умолчанию
  • Возможно на сервере используется интерфейс br0 , который не используется. Попробуйте удалить его

Чтобы завершить сессию VPN, выполните:

nmcli c down [VPNConnectionName]

Создаем PPTP VPN подключение в Linux

Для установки PPTP клиента VPN в Ubuntu/Debian, установите утилиту:

$ sudo apt-get install pptp-linux network-manager-pptp

Добавьте следующее содержимое:

pty "pptp YOUR_VPN_SERVER --nolaunchpppd --debug" name VPNUsername password VPNPassword remotename PPTP require-mppe-128 require-mschap-v2 refuse-eap refuse-pap refuse-chap refuse-mschap noauth debug persist maxfail 0 defaultroute replacedefaultroute usepeerdns

Сохраните файл, нажав CTLR+X, Y -> Enter.

$ chmod 600 /etc/ppp/peers/PPTP

Чтобы подключится к PPTP VPN серверу, выполните:

Настройка SSTP VPN подключения в командной строке Linux

Вы можете настроить SSTP подключение к VPN серверу в Linux. В Ubuntu можно использовать пакет sstp для nmcli.

$ sudo add-apt-repository ppa:eivnaes/network-manager-sstp
$ sudo apt update
$ sudo apt install network-manager-sstp sstp-client

Для подключения к SSTP серверу используется команда:

$ sudo sstpc —cert-warn —save-server-route —user —password usepeerdns require-mschap-v2 noauth noipdefault nobsdcomp nodeflate

Можно сохранить настройки подключения к VPN серверу в текстовый файл:

remotename sstptest linkname sstptest ipparam sstptest pty "sstpc --ipparam sstptest --nolaunchpppd sstpvpn.vmblog.ru" name user1 plugin sstp-pppd-plugin.so sstp-sock /var/run/sstpc/sstpc-sstp-test usepeerdns require-mppe require-mschap-v2 refuse-eap refuse-pap refuse-chap refuse-mschap nobsdcomp nodeflate

Имя пользователя и пароль для аутентификации на VPN сервере нужно задать в файле /etc/ppp/chap-secrets

# Secrets for authentication using CHAP # client server secret IP addresses user1 * xxxxxx *

Теперь для подключения к SSTP серверу с помощью настроенного подключения, выполните:

Чтобы отправить весь трафик через VPN подключение, нужно добавить маршрут:

$ sudo route add default (обычно это устройствл ppp0 )

Или только трафик к определенным подсетям/хостам:

$ sudo route add -net 192.168.2.0/24 dev ppp0

Подключение к OpenVPN серверу из консоли Linux

Для установки пакета OpenVPN в Linux:

  • Debian, Ubuntu, Linux Mint, Kali Linux:
    $ sudo apt-get update && apt-get upgrade
    $ sudo apt-get install openvpn
  • RedHat, Fedora, CentOS, Oracle, Rocky Linux:
    # yum install epel-release –y
    # yum install openvpn –y

Для подключения к OpenVPN серверу вам понадобится файл конфигурации ovpn. Чтобы подключиться к VPN с помощью ovpn файла:

$ sudo openvpn —config /etc/openvpn/client.ovpn —daemon

Введите имя пользователя и пароль (если настроена AD аутентификация для OpenVPN).

Проверьте что VPN подключение установлено:

Чтобы завершить OpenVPN подключение, нажмите CTRL+C (если клиент запущен без параметра –daemon) или выполните команду:

Чтобы OpenVPN подключение автоматически устанавливалось при старте Linux, нужно создать отдельный юнит systemd:

$ sudo vi /lib/systemd/system/OpenVPNClientCorp.service

[Unit] Description=Hide.me OpenVPN Client Corp After=multi-user.target [Service] Type=idle ExecStart=/usr/sbin/openvpn --config /etc/openvpn/client.ovpn [Install] WantedBy=multi-user.target

Измените разрешения на файл:

$ sudo chmod 644 /lib/systemd/system/OpenVPNClientCorp.service

Добавьте юнит через systemctl

$ sudo systemctl daemon-reload
$ sudo systemctl enable OpenVPNClientCorp.service

Источник

Оцените статью
Adblock
detector