Skip to content

Instantly share code, notes, and snippets.

@narate
Last active November 10, 2024 22:40
Show Gist options
  • Save narate/d3f001c97e1c981a59f94cd76f041140 to your computer and use it in GitHub Desktop.
Save narate/d3f001c97e1c981a59f94cd76f041140 to your computer and use it in GitHub Desktop.
Create Wi-Fi Hotspot on Linux using nmcli

Create a Wi-Fi hotspot on Linux using nmcli

Original post : https://unix.stackexchange.com/a/310699

nmcli con add type wifi ifname wlan0 con-name Hostspot autoconnect yes ssid Hostspot
nmcli con modify Hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli con modify Hostspot wifi-sec.key-mgmt wpa-psk
nmcli con modify Hostspot wifi-sec.psk "veryveryhardpassword1234"
nmcli con up Hostspot

Note

If after reboot nmcli con up Hotspot doesn't work

Use this command instead to start Hotspot

UUID=$(grep uuid /etc/NetworkManager/system-connections/Hotspot | cut -d= -f2)
nmcli con up uuid $UUID
@wuseman
Copy link

wuseman commented Jul 23, 2024

Thanks! :-)

@haouarihk
Copy link

haouarihk commented Sep 29, 2024

as an improvement for that command

IFNAME="wlan0" && CON_NAME="wifi name" && PASSWD="12345678" && nmcli c add type wifi ifname $IFNAME con-name "$CON_NAME" autoconnect yes ssid "$CON_NAME" 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared wifi-sec.key-mgmt wpa-psk wifi-sec.psk "$PASSWD"

if the wifi name has spaces it will work

same goes for the second command

nmcli con up "$CON_NAME"

@0827MK
Copy link

0827MK commented Sep 30, 2024

I'm using a macbook.
When I try to connect to Hostspot, I keep getting prompted that WPA password is required.
Even though I used the correct password, the display does not disappear.

@jacobq
Copy link

jacobq commented Oct 3, 2024

Correct me if I'm wrong, but I think adding the following uses WPA2:

nmcli con modify Hostspot wifi-sec.group ccmp
nmcli con modify Hostspot wifi-sec.pairwise ccmp

and for WPA3 maybe something like this:

nmcli con modify Hostspot wifi-sec.key-mgmt sae

(Note: intentional misspelling of hotspot as Hostspot to match OP)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment