So basically, I'd like to use iwconfig to connect to my wifi network when I'm not inside X. But I just don't see a way to do it in the man page. Any idea?
|
|
|||||
|
|
You need the You put your SSID and password into Example:
Assuming your interface is wlan0 you can connect with:
"wext" is a driver and that will be specific for each card; refer to
|
|||||||||||||||||||||
|
|
This link shows it all and worked fine for me: http://linux.icydog.net/wpa.php I'm copying the contents here, so we have it, in case that site goes offline. Command line WPA Sometimes you'll be at a command line with no access to GUI networking tools -- but your access point is secured with WPA. What do you do? Assuming your wireless card actually works (i.e. iwconfig can see it and interact with it), using wpa_supplicant is actually pretty simple. Installing wpa_supplicant Most distros nowadays have wpa_supplicant installed by default. If you have the commands wpa_passphrase and wpa_supplicant available, then you're good to go. Otherwise, you will need to install the package by doing something like (for Ubuntu):
Or (for Fedora):
Or whatever the command is for your distro. Generating the config file Now that wpa_supplicant is installed, we will create its configuration file. Once you know the SSID and WPA passphrase, all you have to do is run:
Of course, replace "myrouter" with the SSID of your router, "mypassphrase" with your WPA passphrase, and "wpa.conf" with whatever file you want to store the configuration in. This filename does not have to follow a particular format or have a particular extension. Alternatively, to avoid typing the passphrase on the command line (so it doesn't get saved in the shell's history), you can specify just the SSID on the command line. wpa_passphrase will wait for you to type in the passphrase followed by enter:
You should end up with a file looking like this:
Getting connected Now we will actually run wpa_supplicant to connect to the wireless network. First, if your router broadcasts its SSID (they all do by default), you probably want to make sure your wireless card can actually see it:
You might have to run that as root to force a refresh. Next, you will need to know three pieces of information:
Now that you have this data, run (as root):
There are no spaces between the options and parameters. Don't include the brackets as I just added those for clarity. For example, for my laptop it looks like this:
You can also run it in the background by using the -B option so that it doesn't take up your console. Now you're associated with the network. Getting online To actually get online, you'll have to get an IP somehow. Most people will just want to get a dynamic IP from a DHCP server, probably the one built into the router. (I'm not going to cover setting a static IP and routing table because that's a beast in itself.) To get a DHCP lease, first release whatever leases you're still holding onto (as root):
Then ask for a new lease (of course replacing eth1 with the name of your network device, the same one as you used in the previous section):
You now have an IP, in theory at least. Happy surfing! |
|||||||||||||||||
|
|
Debian and other distros have wpa_suplicant running as a service by default in order to manage the wifi networks. wpa_suplicant can be handled by different clients/front-ends such as the network manager GUI. This is better explained in this debian wiki. wpa_cli is the command line wpa_suplicant client to manage the wifi networks. Edit: I have just found this post explaining how to use nmcli and it is much better than wpa_cli since it is compatible with the GUI Network Manager and their settings and saved wifi networks. Example of use of wpa_cli: Check that I already have a wifi enabled network interface:
Check if wpa_suplicant process is running:
Enter in wpa client interactive mode:
List available access points:
... and you get something like this:
Add your AP:
Select it as current:
Connect to it:
Check the status:
Exit wpa_cli:
From the shell, request DHCP for an IP and net settings:
|
||||
|
|
|
First brig your card up if it's not runnig:
Set the parameters acording to your network
|
|||||||||||||||||||||
|
|
All the answers suggesting wpa_supplicant are wrong. Yes, it may connect you to the WPA network, but that's a bad solution in the long run because it'll be very difficult to maintain and won't play nicely with a wired connection. Read this answer and make your life easier by using Network Manager from the command line. I wasted hours trying to configure wpa_supplicant, then tried nmcli and it "just worked". |
||||
|
|
|
There's actually a way to do it using NetworkManager, if you have the
(Credit: bug 923836, which came up in my searches on the topic.) |
|||
|
|
|
I had trouble using
I was able to work around it with
I had the network set up by adding it in the wireless section of networking in the GUI, so that I could click on the wired or wireless network icon and select the wireless provider (which was sometimes necessary to complete the login). |
||||
|
|
|
You can use VSWM - Very Simple Wireless Manager. You place your known APs on a simple cfg file (/etc/vswm.cfg) and when you run VSWM is available at https://github.com/dmelo/vswm . Here is a pick of how the vswm.cfg config file looks like:
Under the hoods, it uses the standard command line tools: iwlist, wpa_supplicant, iwconfig, dhclient... Only it automates the job. |
|||
|
|