[Solved] Connecting to WPA2 Wifi via command line

Kernels & Hardware, configuring network, installing services

[Solved] Connecting to WPA2 Wifi via command line

Postby bedtime » 2019-01-24 22:18

I can connect to eth0 but not wifi. My wifi router works as I can see my tablet is connected to it. I am not running this in a graphical environment. The system OS is Debian 9.

Here is what I have:
Code: Select all
# ifconfig
enp7s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.103  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 2001:1970:4f9c:3600:9c13:4a7:bc2:ceec  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::3b79:848b:45c0:5df0  prefixlen 64  scopeid 0x20<link>
        inet6 2001:1970:4f9c:3600:f21f:afff:fe10:9efd  prefixlen 128  scopeid 0x0<global>
        ether f0:1f:af:10:9e:fd  txqueuelen 1000  (Ethernet)
        RX packets 4811072  bytes 7151090543 (6.6 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1502592  bytes 114259116 (108.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 18 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp2s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 6c:88:14:42:d1:f4  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


Code: Select all
#iwlist scan

...

Channel:44
                    Frequency:5.22 GHz (Channel 44)
                    Quality=70/70  Signal level=-36 dBm 
                    Encryption key:on
                    ESSID:"C4BFBB756242-5G"
                    Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
                              36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=00000012ffb4e46a
                    Extra: Last beacon: 2148ms ago
                    IE: Unknown: 000F4334424642423735363234322D3547
                    IE: Unknown: 01088C129824B048606C
                    IE: Unknown: 03012C
                    IE: Unknown: 071E5553202401112801112C011130011195011E99011E9D011EA1011EA5011E
                    IE: Unknown: 200103
                    IE: Unknown: 2D1AEF091BFFFFFF0000000000000000000100000000000000000000
                    IE: Unknown: 3D162C0D0000000000000000000000000000000000000000
                    IE: Unknown: 4A0E14000A002C01C800140005001900
                    IE: Unknown: 7F080100000000000040
                    IE: Unknown: BF0CB2018033EAFF0000EAFF0000
                    IE: Unknown: C005012A00FCFF
                    IE: Unknown: C30402DEDEDE
                    IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00
                    IE: Unknown: DD0900037F01010000FF7F
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : CCMP
                        Pairwise Ciphers (1) : CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown: DD8D0050F204104A0001101044000102103B0001031047001003E16AE9D8A45A7494DE142899D168E010210013436973636F2053797374656D732C20496E632E10230007445043333834381024000744504333383438104200093030303030303030311054000800060050F2040001101100074450433338343810080002210C103C0001031049000600372A000120


Code: Select all
# wpa_passphrase "dlink-DF50-5GHz" "blahblahpassword" > /etc/wpa_supplicant/wpa_supplicant.conf
# cat /etc/wpa_supplicant/wpa_supplicant.conf
network={
        ssid="dlink-DF50-5GHz"
        #psk="mypasswordishere"
        psk=a588c892BLAHBLAHBLAHHHHHHHH4a49036467816f456cc7
}


Code: Select all
# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

auto enp7s0
allow-hotplug enp7s0
iface enp7s0 inet dchp

auto lo
iface lo inet loopback

auto wlp2s0
iface wlp2s0 inet dhcp
   wpa-ssid "dlink-DF50-5GHz"
   wpa-psk "a588c89256dbBLAHHHHHHHHHHHHHHHHHHHHHa49036467816f456cc7"



Code: Select all
#ifup wlp2s0
ifup: /etc/network/interfaces:9: unknown or no method and no inherits keyword specified
ifup: couldn't read interfaces file "/etc/network/interfaces"


I had this working when I used just WEP mode on the modem, but it was slow (you could actually see the page slowly printing on the screen). As of now, the system boots and then stops for about 2 minutes trying to connect before it lets me in. I am then connected to enp0 (eth0). If I disconnected the network cord then enp0 disconnects but no wifi. Plugging back in brings enp0 up again. So hotplug is working, and the system appears to be reading the /etc/network/interfaces file.

Any ideas?
Last edited by bedtime on 2019-01-29 13:28, edited 1 time in total.
bedtime
 
Posts: 107
Joined: 2012-12-16 19:34

Re: Connecting to WPA2 Wifi via command line

Postby Bulkley » 2019-01-25 00:02

/etc/network/interfaces

Code: Select all
# The loopback network interface
auto lo
iface lo inet loopback

#Wifi
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "my ISP router"
wpa-psk "my password"


That does it for me.

BTW, did you install any non-free firmware necessary for your Wifi card?
Bulkley
 
Posts: 5723
Joined: 2006-02-11 18:35

Re: Connecting to WPA2 Wifi via command line

Postby Head_on_a_Stick » 2019-01-25 05:31

Can you connect manually?
Code: Select all
# ip link set wlp2s0 up
# wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant/wpa_supplicant.conf
# dhclient wlp2s0

Post any error messages in full, thanks!
"The trouble with the world is that the stupid are cocksure and the intelligent full of doubt." — Bertrand Russell
User avatar
Head_on_a_Stick
 
Posts: 8838
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Connecting to WPA2 Wifi via command line

Postby bedtime » 2019-01-25 12:27

Bulkley wrote:/etc/network/interfaces

Code: Select all
# The loopback network interface
auto lo
iface lo inet loopback

#Wifi
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "my ISP router"
wpa-psk "my password"


That does it for me.

I got it working, and your setup is just about exactly what mine looked like in the end (exception that wlan0 was replaced with wlp2s0). :)

BTW, did you install any non-free firmware necessary for your Wifi card?

Yes, I installed the drivers. Easy to forget though.

Can you connect manually?

At the time, no; I tried all three methods. I think the issue was that I had some extra parameters in my /etc/network/interfaces (pairing and such) that didn't agree with it. Also, I had wpa_supplicant running by systemd, and I'm thinking that it was interfering with dhcp. I simply disabled it and enabled dhcp.

An issue that I'm having right now is that I've seemed to lose my ethernet (eth0—enp7s0, in my case). When I plug it in, it should connect, but it doesn't.

Here is what I have:

ifconfig -a (ifconfig alone does not bring it up):
Code: Select all
enp7s0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether f0:1f:af:10:9e:fd  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 18 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2  bytes 78 (78.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 78 (78.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.210  neenp7s0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether f0:1f:af:10:9e:fd  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 18 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2  bytes 78 (78.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 78 (78.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.210  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::6e88:14ff:fe42:d1f4  prefixlen 64  scopeid 0x20<link>
        inet6 2001:1970:4f9c:3600:6e88:14ff:fe42:d1f4  prefixlen 64  scopeid 0x0<global>
        ether 6c:88:14:42:d1:f4  txqueuelen 1000  (Ethernet)
        RX packets 287224  bytes 421958333 (402.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 145569  bytes 15207757 (14.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
tmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::6e88:14ff:fe42:d1f4 prefixlen 64 scopeid 0x20<link>
inet6 2001:1970:4f9c:3600:6e88:14ff:fe42:d1f4 prefixlen 64 scopeid 0x0<global>
ether 6c:88:14:42:d1:f4 txqueuelen 1000 (Ethernet)
RX packets 287224 bytes 421958333 (402.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 145569 bytes 15207757 (14.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0



/etc/network/interfaces:
Code: Select all
auto enp7s0
allow-hotplug enp7s0
iface enp7s0  inet dhcp


auto lo
iface lo inet loopback

auto wlp2s0
iface wlp2s0 inet dhcp
   wpa-ssid C4BFBB756242-5G
   wpa-psk a5d0f6c870BLAHBLAHBLAHfe0a81


*** EDIT ***

After adding enp7s0 back, it somehow works, too. :roll: Anywho, it all works now! Eth0 is able to be plugged/unplugged and is activating as it should, and the whole universe is following the laws of nature! :D

Weird thing, but now my remote SSH session is back up to regular speed and not extremely slow. Not exactly sure what fixed that, but I'm not complaining! :P

Thank you guys for your replies!
bedtime
 
Posts: 107
Joined: 2012-12-16 19:34

Re: Connecting to WPA2 Wifi via command line

Postby Head_on_a_Stick » 2019-01-25 17:38

bedtime wrote:I think the issue was that I had some extra parameters in my /etc/network/interfaces (pairing and such) that didn't agree with it

There are no such parameters in the file you posted :?

bedtime wrote:I had wpa_supplicant running by systemd, and I'm thinking that it was interfering with dhcp. I simply disabled it and enabled dhcp.

Nope, dhcp has nothing to do with wireless authentication.

An enabled wpa_supplicant.service may conflict with ifupdown though.
"The trouble with the world is that the stupid are cocksure and the intelligent full of doubt." — Bertrand Russell
User avatar
Head_on_a_Stick
 
Posts: 8838
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Connecting to WPA2 Wifi via command line

Postby bedtime » 2019-01-25 21:06

Head_on_a_Stick wrote:
bedtime wrote:I think the issue was that I had some extra parameters in my /etc/network/interfaces (pairing and such) that didn't agree with it

There are no such parameters in the file you posted :?

And now you see first hand what desperation can do to a man. :roll:

bedtime wrote:I had wpa_supplicant running by systemd, and I'm thinking that it was interfering with dhcp. I simply disabled it and enabled dhcp.

Nope, dhcp has nothing to do with wireless authentication.

An enabled wpa_supplicant.service may conflict with ifupdown though.

Could be a number of other small changes I made.

There is an additional issue, though, and that is that connecting to SSH (SSH alone or with X11 forwarded) via wireless is very slow. One can see the web pages forming and the screen tearing. Watching a YouTube video is not pleasant. Connecting with eth0 is fine.

I'm not sure where to start looking (router, server, host...). Wifi without SSH is fine; Firefox is fast. Android phone is connected to that wifi and the net is fast.
bedtime
 
Posts: 107
Joined: 2012-12-16 19:34

Re: Connecting to WPA2 Wifi via command line

Postby Head_on_a_Stick » 2019-01-26 10:43

bedtime wrote:
Head_on_a_Stick wrote:
bedtime wrote:I think the issue was that I had some extra parameters in my /etc/network/interfaces (pairing and such) that didn't agree with it

There are no such parameters in the file you posted :?

And now you see first hand what desperation can do to a man. :roll:

We can't solve your problem if you don't provide all of the relevant configuration files, desperation has nothing to do with it.
"The trouble with the world is that the stupid are cocksure and the intelligent full of doubt." — Bertrand Russell
User avatar
Head_on_a_Stick
 
Posts: 8838
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Connecting to WPA2 Wifi via command line

Postby bedtime » 2019-01-27 10:35

Head_on_a_Stick wrote:We can't solve your problem if you don't provide all of the relevant configuration files, desperation has nothing to do with it.

Yes, I didn't post enough information. Sometimes I don't want to overwhelm the reader with too much info.

I found out why the network was so slow. It was very likely the fact that I was using SSH to forward X11; it seems that this is an inefficient way to do it. When I switched to using VNC, the video was perfect with very little tearing at all. I'm still using SSH for sound.
bedtime
 
Posts: 107
Joined: 2012-12-16 19:34


Return to System configuration

Who is online

Users browsing this forum: No registered users and 8 guests

fashionable