Connecting to network with terminal

command linenetworkingwifi

I have a router at home with ESSID of dlink_home and 10 digits (0123456789) 64-bit WEP encryption of Open Authentication Type.

I want to connect to it through terminal with bash commands, I tried

ifconfig wlan0 up
iwconfig wlan0 essid dlink_home key s:0123456789
dhclient wlan0

When using s: prefix it gives the following error:

Error for wireless request "Set Encode" (8B2A) :
SET failed on device wlan0 ; Invalid argument.

and without it, it doesn't work, as s: prefix is for specifying string key rather than HEX key.

The OS I am running is Red Hat Enterprise Linux 6.

Best Answer

1. correct form of the command

Try changing your iwconfig line to this:

$ iwconfig wlan0 essid dlink_home key s:0123456789

2. wpa_supplicant

If the above command is correct and you're still receiving an error message, make sure that you have the wpa_supplicant package installed.

$ yum install wpa_supplicant

3. NetworkManager

I'd use NetworkManager over iwconfig when dealing with wireless devices. To connect via command line using NetworkManager in runlevel 3 you can use the following command:

 $ nmcli dev wifi connect <name> password <password>

References

Related Question