Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

How to setup Wifi using the command-line?

Writer Mia Lopez

How do I setup Wifi using the command line?

I need to setup as following, but its failed:

Target:

Security: WEP
Network name: wifi59/7
Key/password: xyz

Tried and failed:

sudo iwconfig wlan0 mode managed
sudo iwconfig wlan0 channel 11
sudo iwconfig wlan0 essid wifi59/7
sudo iwconfig wlan0 key xyz
Error for wireless request "Set Encode" (8B2A) : SET failed on device wlan0 ; Invalid argument.

4 Answers

The WEP key should be in hex, and either 10 or 26 characters long (5 or 13 ASCII bytes).

If you want to specify it in ASCII, you have to prefix it with s: - I'm not sure if iwconfig will pad out an ASCII password, but try lengths of 5 or 13.

See man iwconfig and scroll down to key/enc[ryption] for some examples.

1

I think it is easier and more reliable to use networkmanager's default command line utiliy called nm-cli. Please have a look at nm-cli to familiarize yourself with nm-cli syntax.

This is my solution:

$sudo vi /etc/network/interfaces
#The primary network interface
auto wlan0
iface wlan0 inet static
# wireless-* options are implemented by the wireless-tools package
wireless-mode managed
wireless-essid YOUR_SSID
wireless-key1 s:YOUR_PASS
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 200.48.225.130 200.48.225.146
vim /etc/netplan/50-cloud-init.yaml

and insert the following configuration stanza while replacing the SSID-NAME-HERE and PASSWORD-HERE with your SSID network name and password:

wifis: wlan0: optional: true access-points: "SSID-NAME-HERE": password: "PASSWORD-HERE" dhcp4: true

Make sure that the wifis block is aligned with the above ethernets or version block if present.

Source

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy