Page MenuHomeVyOS Platform

Wireguard QR code in cli for mobile devices
Closed, ResolvedPublicFEATURE REQUEST

Description

Since Wireguard app for iPhone and Android support reading configuration from a QR code.
Would be nice to be able to write "show wireguard wgX peer $peer-name qr-code" or similar where the QR code with configuration for the mobile devices is shown for easy scan or quick export later on when/if a web-ui with api access is created.
Fortunate there is already a package that can do this called qrencode/libqrencode Github page

Debian wiki describes how this is done on a debian server.
Import_by_reading_a_QR_code

also a blog that shows how he creates QR codes in Debian
importing-wireguard-configs-on-mobile

Details

Difficulty level
Normal (likely a few hours)
Version
-
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible
Issue type
Feature (new functionality)

Event Timeline

The suggested debian package qrencode seems handy for terminal use. Actually, using QRcodes to transfer information would be interesting for other uses as well, such as exporting other kinds of keys such as OpenVPN. As a remote support measure, if a config is causing issues that prevent remote login, having a local login being able to emit the current config as a QRcode might be interesting...

syncer triaged this task as Wishlist priority.Nov 14 2019, 1:00 AM

I tested by just adding default debian buster repos and run

sudo apt install qrencode

Note it requires following packages: libpng16-16, libqrencode4
But it worked like a charm.

then i created a dummy config file for wireguard server in my users home folder ( cannot remember here the config files are located on VyOS)

[Interface]

Address = 10.0.0.1/24

ListenPort = 51820

PrivateKey = wPWL7ilc1r+ciTAVKyx7bVtPsL5KMlOL76/2599CXlM=

PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE



[Peer]

PublicKey = MYIH2GVRYHocypdAokGZAgLICW7/kK12KjPnlD1Dpkw=

AllowedIPs = 10.0.0.2/32



[Peer]

PublicKey = 2M/AkJUNPrVlhohGTxjSa93oLYIhtdEO83zKZbYszTc=

AllowedIPs = 10.0.0.3/32



[Peer]

PublicKey = 9Ee2bDXoa1PI5J6SySLfWLa51J3+DHu6LbOkISwKRyw=

AllowedIPs = 10.0.0.4/32

finally i test it out

[email protected]:~$ sudo qrencode -t ansiutf8 < test.conf
█████████████████████████████████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████████████████████████████████
████ ▄▄▄▄▄ █ █▄███ ▄██▄▄ ▀▄██ ▄█▀█ █▄▀ ▀█▄▀▄▄ ▄█▄▄▀▀ █  █▀█ ▄▀  ▀▀▄▀▄▄▀█▄█ ▄▄█ ▀▄█ ▄▄▄▄▄ ████
████ █   █ █ ▀█▄▀ █▄▄█  █▄▄█▀▀█▄  ▀██  ██▀▀▄▀ ▀▀▀ ▄▄█ ▀▄▄▄▀▀▀▄ █▀█▄    █ ▄▄▀ ▀▄▀██ █   █ ████
████ █▄▄▄█ █▀▀▄ █▀▀▄ ▄ █▀ ▄▀▀▀▄  ▄▄▄ ██▄ ▄▄█ █ ▀███▄▀  ▄ ▄▄▄ ▄▀    █▀██ ▄▀█▄▄ ▄▀██ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄█▄▀▄█ █ ▀▄▀ ▀▄█ ▀▄█ █▄█ █▄▀▄█▄█ ▀▄█ ▀▄▀▄█▄▀ █▄█ ▀▄▀▄▀▄▀ █ █▄▀▄▀▄▀ █▄█▄▄▄▄▄▄▄████
████  █▀▄ ▄▀▀▀ █▄█▀  ▀▄█▄▄██▄▀ █▄▄▄  █▀▄█▄▀▀██▀ ▀█▄██▄▀▄▄   ▄▄█▄▄█▄ ▀█▀▀▄▀█  ▀▄▀▀██ █ ▄▄ ████
████▀ ▄█ █▄▄▀▀▀▄▄ █ ███ ▄ ▀ ██▀▄▀▀███▄▀█▄██▄▄▄███ █▄▄▄█▀▄▀ ▀▄▄  ███▀█▀█▄▄█▄ ▄█▀█ ▄▄██  █▀████
████████▀ ▄█▀▀ ▄▀▀█▄█ █▄▀▀▀█▀▀▄ ▄▀██ ███  ▀█▄▀▀  ▄█   ██▄▄▄█▄▀▄▀▄▀ ▀▀▀▀█ ▄█▀▀█ ██▄▄ ▄ ▄▀▀████
██████▀▀ ▄▄█▄█ █▄▄▄▄█▄▀ ▄██▀▀█▄▄▀▄██▄▀ ▀█ ▀ ▄ ▄▀▄█  ▄▄█ █▀▄▄█ █▀ █  ▄▄ ▄▄ ▄▀█▀▀█▄▀▀ █▀ ▀▄████
█████▀▄ ▀▄▄██ ▀██▄▀▄▀ ▄▄▀▄▀██ ▀ █▀ ▄▄▄█▄▀▄█▀▀█ ▀ ▀ ▀▀  ▀█▄ ▄▀ █  █▀ ▄▀ ███▄█▀▄ ▀█▀▀  ██▀ ████
█████▀▄ ▀▀▄██ █  █▄   ▄█   ▄▀▀▄▄ ▄ ▀ ▀▄ ▀██▄▀ ▀██▀█▄▀▄▄▄▀ ▄ ▀ █▀█▄█▀▄ ▄ ▄▀▀█▄▀▄▀█▀ █▄▀▀▀▄████
███████▀█▀▄▀▄ ▄▄▄█ ▀  █▄ █▄▄▄▀ ▄█▄▀▄█▄▄█▀▀▄█▀▄ █▄▄ ▀▄▀▄▀▄█▀ ▀▄▀▀ ▀ █▄█ ▀▀▄▀█▀▀ ▀▄█▄ ██▄█▀████
████▄▄▀ ▄ ▄█▄▄▄ ▀ █▀ █▀▀▀▄▄ █▄█ ▄▀██ ▀ ██   █▄█▄▀▀▀█▀▄█ ███▄ █  ▄▀█▀███ ██  █▀▄█ ▄▀▀▄▄█  ████
████  ▀ █ ▄▄▄▄▀█▀ █ ▄▄▄ ▀▀ ▀█  █▀▀█▀ ▄▀ ▄█▀███    █▄ ▄ ▄█▀ █ █▀█ ▀█▄ █▄▄▀ ▀█▀█▄█ █▄ ▀ ▀█▀████
████ ▀  ██▄█ ▀█▄▄█ ▀▄▀ █▀▄███▄ ▀ ▄██ ▀▀▄█▀█▄▄ ▄█▀ ▀▄█ ██▄ ▀ ▀▀  ▄▄▀▄ ▄██▀  █ ▄█▀▄ ▄▀▄▄█  ████
██████▀▀ ▄▄▄ ▀▀█▀▄ ▀  ▄▀▀▀▄▄▀▀▄▄ ▄▄▄ ▀█▀██▄█ █▀▄▄▀ ▀██▀█ ▄▄▄  ▄ ▀▄▄▀ ▀█ █ ███  █ ▄▄▄ █▀▀█████
████▀▀▄  █▄█ █▄▄▄█▄▄▄▀█  ▄▄██▀▄█ █▄█  ▄▄▄█   ▀ █ ▀  ██▀  █▄█ █ ▀▄▄ █▄▄▄▀▀█▄▄▀ ▀  █▄█ █  ▀████
█████▀▀▀ ▄▄▄▄██▀▀ ▄▄▀▀▀ ▄█ ▀▀▀ ▄ ▄▄ ▄█▄▀  █▄  ▀ ▀▄ █ █▀▀ ▄▄▄ ▄▀█▄▀▄ ▀▀ ▄ ▀▄▀ ▀ █▄ ▄ ▄█▄▀▀████
████▄▄▀ ██▄  ▄ ▀▀██ ▀█████ █ ▄█ ▀ █▀ ▄ ▄████▀▄▄██  ██▄█▄▄▄██▀█▄ ▀ █ ▀██▄▄▄█▀▄█ █▀ ▀█▀ ▄▀▀████
██████ █  ▄  █▀█▄  ▄██▀▀▀█▀ ▀▀▄▄██▀ ▀█▀█ ▀  █  █▄▀▄ ▀▄ ▄▄█▄▄  ▄ ▀▀ ▀▄█ ▄▄ ▀▄█ █▄▄  ▀▄▀▄ ▄████
████   █▄ ▄ █▀▀ █▄▄▄  ▀ ▀  █▀  ▀   █▀██▀██▄ ▄█▀ ▄▀▄▀ ▄█  █ ██▄▄▄▄█▀ ▀ ▄ ▀ █▄▀▀   ▄███▀  ▄████
██████ █▀ ▄▄▀▄ ██▀▄ █ █ ██▄██▀▄▀ █▀▄█▀ ▀ ▀ ▀▀▀█▀ █▀█▄▀▀█  ▀ ▀▀█▀ ▄▀▀▄▀▀█ ▄▄▄▀▄▀ ▀█▀█▄█ ▀▀████
████▀▀▀▀█ ▄ █ ▀▄     ▄▄▀  ▀▄▀▀█  █▀█  ▄▄▄▄▀▄▀ █▀▄  ▄██▄█▀ ▀ ▄▄█▀▄  █▄▄▀ █ █▄▄▄█ ███ ▄▀▀▀▀████
████▄█ █▀▀▄▀███ █▀▄█▀▀  ▀ █▀ ▀▀█▀▀█▄▀ ▄███▀   ▄ ▄▄▄▄▄▀▄▀▀  ▀▄▄▀ ▄  ▀▄▄ ████▄  ▄█▄██▀ █ ▀▀████
████▄▀▄█▄█▄▀▄▄ ▀█ ▀▀█▄ █▀█▀▀██▄▄  ▀▀█▄ █ ▀▀▀▄ ▄▄▀  █▀▀█▄ ▀█ ▀▀█ █▀ ▀▀ █ ▀▀▄▄▀▄▄█ ▄█▀ █ ▀ ████
██████▄▄▄█▄▄▄█  ▄ █▀█▄ ▄▄█▀█    █ █  ██▀ ▀▀██▀ ▄▄▀▄    ██▀▄▀▀███▄█▄▄▄▀ ▄▀ ▀▄▀█ ██  ▄▀▄██ ████
████▀▀█ ▄ ▄▀▄▄██ ▀▀ █▄█▄▀ ▀ ▀█ ▀█▄█▄ ▀▄ █▄ ▀   ▀█▄▀ ▄ ▄▀ ▀▄▄█▀  ▀▄██ ▄ █▄█ ▄▀▄█▄▀▀ █ ▄▀ █████
████▀▀▀▄ ▄▄▄  ██▄█▄ ▀██▀▀███▀▄▄  ▄▄▄  ▄▀▀▀▀█  ▄▀▄ ▄██ ▀▀ ▄▄▄ ▄█▀▀█▀██▀█▀▀▀▀▀ ▄▀  ▄▄▄ ▀ █▄████
████▀▀█▀ █▄█ ▄▄▀█▄  █████▄ █▀▀▄▄ █▄█ ▀█ ▄▄█▄▀▀▄█   ▄█▄█▄ █▄█ ▄  ▄█▀▄ ▀  ▀ ▄▄▀ ▀  █▄█ ▄▀▀▄████
████ █▄▄▄ ▄  ▄█▄▀▄ ▄█▄█▄▀▄██▄▀ ▀▄ ▄ ▄█ ▄█▀█▀█ ▀   ▄▄  █▄▄▄ ▄▄▄█▀ ▀  ██ ▀ ▀ ▀ ▀▄▄▄ ▄▄ ▄▄▀▀████
████▀ ▀ █▀▄▄▀▄▄██▄▄▀▄▄▄ ▄   █▀▄ ▀▄▄█▄▄ █▄▄▀   ▄███ ▄██▀ █ ▀██▀▀▀ ▀█ █▄██▄▄  ▄▄█▄█▄▀▄▄   █████
██████▄▀▄█▄▀ ▀█▄▄ ▀█▄ █▄▀▀▀▀▀▀▄▀▄▀   █ █   █ ▀   ██ █▀▀▄██▄█▄ ██▀ █ ▄▄▀ █▄█▄▄█▄█████▀█▀█ ████
████▄▄██ ▀▄   ▀  ▀▀▄ █▄ ▀██▀ ██▀▄ ██▄ ▀▀▀▀▀▄█▀██ ▀▄  ▄▀▄   ▄█▄█  █▀██▄▄▀  ▄▀█▀▀█ ▄▀ █   ▄████
████ ██ ▄ ▄  █▄▄▄▀▀  ▀   ▄▀█  ▀ ▀  ▀▀▄█ ▀▄█▀ ▄ █▀ █ ▄ █▀▄   ▀▀█▀▀█ ▀▄ ▀██ ▄█▀█▀█ ▄ ▀▄▄   ████
████▄▀  ▄█▄▄█▀▄  ▄  ▀█▄█ ▀  ▄ ▄█  █▀█▀▄▄██▀ ▀▀▀█  ▄ ███▄▄  ▄▀ █▀ ▄▄ ▀  █▀▄ █▄█▀ █▀▄██▀█▄▀████
████▀ ▀  █▄▀ ▄██ ▄█▀▄▀█ ▀▄█▀▄▄▄▄▀▄ ▀▄█   █▀▄ ▄ ▀█▄ ▄█▄ █▀██▄▄ █▀    ███▀██ ▀  ▀▀ ██   ▀▀▀████
████ ▀  ██▄▀    ▀█▄▄█ ▄▀▀▀▀  ▀▀ ▀▄███▄▀ ▀▀▄█▄▄▀ ▀▄█▀▀▄▀█  ▄▄    ▄▀ ██▄▄▄▄▀ ▀█ ▄█▄▄▀█▀▄▀▀█████
████  █▄▀▀▄█ ▄▀▀▄   ▄ ▄ ▄▀██▄█ ██▀  ▀ ▀▀▀▄  █▀▀█ ▀█▄ ▀▀█ █▀▀ █  ▄▄▄▀█▀▀▄▀▄▀█▀█▄█ ▄▄▄████ ████
████▄ ▄▀▄▀▄ ▀▀▄█▀▀▄▄█▄█▀▀   ▄▀ ▄▄▄█▀▀ ██▄▄ ▄▄▄▄▄▀ ▀▄█▀▄▀██▀ ▄▀▀▄▀▄▀█▄▀ ▄▄  ▄ ▀██▀ ██▄ █ ▀████
████▄█████▄▄▀▀ █▀▀█ █▄▀ ▀ █ ▄█▀▀ ▄▄▄ ▄█▀▄█▀▀ ▄ ▄▄█▄▄  ▀  ▄▄▄ █▄▀ ▀ █▄ ▄  ███▄    ▄▄▄ ▀▄█ ████
████ ▄▄▄▄▄ █▀█▄██▄▀▄▀▄▄ ▀▄▀ █▀▀  █▄█   ▄██▀  ▀▄██ ▄ ▀█▄  █▄█  ▄▄ ▀█ ▀▀▀█▄   ▀ ▀  █▄█ ▄  ▄████
████ █   █ █▄▀▄██▀ ██ ▀ ▄▄█▀▀▀▄▀ ▄  ▄ █▀ ▀ ▄  ▀  ▄ ███▀█   ▄▄▄█▀▄▀▄ ▀▀▄▀ ▄▀▄ █▄▀   ▄▄█▄▄▀████
████ █▄▄▄█ █▀█▄▀█▀▄  █ ██▄▀█ ▀   ▀▀▄▄▀  ▀██▀▀█▄████▄█▄  ▀ ▀▄▄ ▀▀▄   █▄█▄  ▄▀▄█▄▄█▀▀▀  ▄ █████
████▄▄▄▄▄▄▄█▄▄▄█▄▄██▄▄▄▄▄▄██▄█▄██▄███████▄▄███▄█████▄█████▄█▄▄▄██▄▄▄████████▄▄██▄▄██▄▄▄▄▄████
█████████████████████████████████████████████████████████████████████████████████████████████
███████████████████████████████████████████████████████████████████████████████████████████

Seems to work fine as in it generates a QR Code which contains what was listed above.
Only thing that the client is unable to import is the postup and postdown in line 5 and 6 under the [Interface] section.

If someone could point me in the direction where wireguard config files are stored in VyOS i will be happy to test it out further.

this implementation would ba an operational mode command. THose are deinfed here: https://github.com/vyos/vyos-1x/blob/current/op-mode-definitions/wireguard.xml and package dependencies life here https://github.com/vyos/vyos-1x/blob/current/debian/control

Did the changes on dependencies file here: https://github.com/Maltahl/vyos-1x/commit/27400e09b27d98b6ee34568fe25828cff1d14770

I have a hard time wrapping my head around getting the correct output from wireguard.xml

PR created https://github.com/vyos/vyos-1x/pull/498

@c-po i might need some assistance on getting the correct outputs from VyOS from wireguard.xml
to generate a proper QR code with the following formatting:

[Interface]
PrivateKey = abcdefghijklmnopqrstuvwxyz1234567890=+
Address = YOUR_VPN_PRIVATE_IP/24
DNS = 1.1.1.1, 1.0.0.1

[Peer]
PublicKey = YOUR_SERVER_PUBLIC_KEY
AllowedIPs = 0.0.0.0/0
Endpoint = YOUR_SERVER_WAN_IP:51820
(20:28) vyos_bld 3dd4a86280b8:~ # cat key.txt
[Interface]
PrivateKey = abcdefghijklmnopqrstuvwxyz1234567890=+
Address = YOUR_VPN_PRIVATE_IP/24
DNS = 1.1.1.1, 1.0.0.1

[Peer]
PublicKey = YOUR_SERVER_PUBLIC_KEY
AllowedIPs = 0.0.0.0/0
Endpoint = YOUR_SERVER_WAN_IP:51820
(20:28) vyos_bld 3dd4a86280b8:~ # qrencode -t ansiutf8 < key.txt
█████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████
████ ▄▄▄▄▄ █ ▀█▀▄  ▄ ▀ ▄  ▄ ▀▀▄  ▀ ▄  ▀█▄▀▄▄ █ ▀██ ▄▄▄▄▄ ████
████ █   █ █ ██▀▄▄▄▀▀▀█▄▀█ ██▀▄▄ ▄▀▀ █▄█ ▄██ █▀▄▀█ █   █ ████
████ █▄▄▄█ █▀▀ ██▀ █▀▄▀▀▀▀▄▀ ▄▄▄ █  ▀ ▀▀▀ ▄ █  ███ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄▀▄▀ ▀▄▀ █ ▀▄█ ▀ █▄█ █▄█ ▀▄█ ▀ ▀▄█ ▀▄█▄▄▄▄▄▄▄████
████▄▄▀█▄▄▄▀██ ▀▀▄ ▄███▀▄▀▀▀ ▄   ▀▀ ▀ █ ▄▄ ▄▀▄ ▀▀▀█▄█▄ ▄ ████
█████▄ ▀██▄▀█ ▄▀██▀▀  ▀▀█▀  ▄ █▀█ ████▀▀█▀▄ ▀▄▄██▄▀ █▄█▀ ████
████ ▄▄▀█▄▄▀▀ ▄█ ▀█▀▀█ ▄ ▀█  █  █▀█▄▄▀▄▄█▄▄▀█  ▀▄█ ▄█▄  ▀████
████  ▄ ▀▀▄ █    ▄  ▀▄▀▀█▀  ▄▀ ▄▀▄▄▀▀▀▄█▀▀▀▀▄▀█ █▀▄█▀ █▄▀████
████▄  ▀▀▄▄█ ▄▀▄ ▀▀▀▀  ██ █  ▄▀▄█▀▀ ██▄▄▄█  █▀  ▀ █▄ █▀ ▀████
████▄█ █▀ ▄▀▀▀▀▀█▀▀▄█▄▀ ██ ██▄█▄▄ ██▀█ ▀█▀▄▄█▄▄▄▀█▀ ▀▀▄▀▄████
█████   ▀▄▄   ▄▄   ▄█ ▀ █▄█  ▄▀▄█▄▀▀█▀▄▄█ ▄ ▄▄   █▄█▄▀ ▄ ████
████▄▀ ▀ ▀▄█▄▀  ▀▀█▀▀▄▀███  █ ▄ ▄▄█▀█  █▀ ▀▀▄ ▄█▄█▀██▀▄ ▀████
████ ▄ ▄ ▄▄▄ ▄▄█▀▄ ▄█▀ ▄██▀▄ ▄▄▄ ▄▀████  ▄▀▄█  █ ▄▄▄ ▄▀█▀████
████▀ ▀▄ █▄█  ▀▀▄█▀▀  ▀▀█▀ ▀ █▄█  ▄██▄▀██▀▄ █▄▄▄ █▄█ ▀▄█ ████
████▀  ▀▄▄▄▄▄▀▄▄ ▀█▀ █ ▄  █ ▄  ▄▄▀█▄▄█▀█   ▀█ ▄▀▄▄   █ █ ████
█████▀▄▄ █▄ ▄▄ ██▄  ▀▄▀▄▄█ ▀▀ █▄ █▄▀█▀▄█▀  ▀▄▀▄█ ▀▄  ▀▄ ▀████
████▀▄ █▀ ▄ ▄▀  ▀▀▀▀▀█▀▀ ▄▀▀███▀▄▀▀ ▄▀█▄ █▀ ▀▀▀█▀▄█  ▄▀██████
████ ▀█ ▀█▄   ▀ ▀▀▀▄█▄▀▀██ ▀ █▀█▄▀██▄█▀▀▀ ▄█ ▄▄▀▀▄██▄▄▄█▄████
████ █ ██ ▄ ▀▄▄▄▀  ▄█▀  ▀  █▀  ▄▄▄▀ ▄▄██▀█▄▄█▄ ▄▀▀██  ▀▀▄████
█████▄▀█▀▀▄█▄▀█▄ ▀█▀▀▄▀▄▄▀ ▀  █▄█▄███ ▄▄▀▄▄▀▄▀▄▄██▄█▀ █▄▄████
████▄▄▄▀▄▄▄▀  ▀█▀▄ ███▄█▀ █▀▄▀▄▀▄▄▀▀  ▄ ▄▄ ▄▀ ▀▄ ▄▀█ ▄▀▀█████
████▄ ▀▄▄▄▄ ▀▄▀ ██▄   ▀ █▀ ▀▀▀▀  ▀▄▀██▀▄█ ▄▀▄▄▄█▀█ ██ ▀█▄████
███████▄██▄▄▀▄▄▀▄▄ ▀ ▄███▀▄█ ▄▄▄ █▄██▄▄▀▀ ▄ █▀ ▄ ▄▄▄ ▀ █▀████
████ ▄▄▄▄▄ █▀ █▀▄▀  ▀▄▀█▄█   █▄█ ▄▄▀█▀▀█▀▄▄▀▄██▀ █▄█  ▄▀█████
████ █   █ █▄ █▄▀▄██ █ ███▀█▄▄▄▄ ▄▀█ █▄▄▄█  █▀ ▄  ▄   ▀▀▀████
████ █▄▄▄█ █▀ ▄▀▀█   ▄▀ ██  █ █▄ █▄██▀▀▄█ ▄▀▄▄▄▀ ▄ ███▀  ████
████▄▄▄▄▄▄▄█▄▄▄███▄▄██▄▄▄███▄█▄▄██▄▄▄█▄▄▄▄▄██▄▄█▄█▄▄▄▄█▄█████
█████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████
c-po changed the task status from Open to In progress.Apr 24 2021, 1:38 PM
c-po claimed this task.
c-po changed the task status from In progress to Backport pending.Apr 24 2021, 4:14 PM
c-po added a project: VyOS 1.4 Sagitta.
c-po changed Difficulty level from Unknown (require assessment) to Normal (likely a few hours).
c-po changed Is it a breaking change? from Unspecified (possibly destroys the router) to Perfectly compatible.
c-po moved this task from Need Triage to Finished on the VyOS 1.4 Sagitta board.
c-po moved this task from Need Triage to Finished on the VyOS 1.3 Equuleus board.
erkin set Issue type to Feature (new functionality).Aug 31 2021, 6:19 PM