3

To authenticate in a corporate network I have to run the following command:

$ sudo wpa_supplicant -i eth0 -D wired -c /etc/wpa_supplicant/mywired.conf -B

The configuration script loaded thereby looks like this:

# global configuration
ctrl_interface=/var/run/wpa_supplicant
#ctrl_interface_group=wheel
ap_scan=0

# 802.1x wired configuration    

# eap-ttls
network={
    key_mgmt=IEEE8021X
    eap=TTLS
    identity="[email protected]"
    anonymous_identity="[email protected]"
    password="password"
    ca_cert="/home/user/deutsche-telekom-root-ca-2.pem"
    phase2="auth=PAP"
    eapol_flags=0
    priority=5
}

# eap-peap
network={
    key_mgmt=IEEE8021X
    eap=PEAP
    identity="[email protected]"
    anonymous_identity="[email protected]"
    password="password"
    ca_cert="/home/user/deutsche-telekom-root-ca-2.pem"
    phase2="auth=MSCHAPV2"
    eapol_flags=0
    priority=10
}

Without the configuration I do not get an IP address assigned via DHCP.
How can I automatically apply this configuration at startup? I am running Ubuntu 14.10.

2 Answers 2

3
+50

If you want wpa-supplicant to run using that config upon boot, then you should put the command in rc.local.
As root, open up /etc/rc.local in a text editor and paste in your command:

wpa_supplicant -i eth0 -D wired -c /etc/wpa_supplicant/mywired.conf -B

Make sure that Systemd is running rc.local:

sudo systemctl enable rc-local

and reboot. Should work.

EDIT:

Failing that, you can also just write your own systemd rule.

First, save your wpa-supplicant command to somewhere sensible, like /usr/local/bin or /opt and make it executable.
The file should look like this:

#!/bin/sh
wpa_supplicant -i eth0 -D wired -c /etc/wpa_supplicant/mywired.conf -B

Let's assume you have called it wpastart.sh.
Now create a file in /usr/lib/systemd/system and name it something like wpa.service.
Open the empty file in a text editor and make it look like this:

[Unit]
Description=WPA Supplicant Startup

[Service]
Type=idle
ExecStart=/usr/local/bin/wpastart.sh

[Install]
WantedBy=multi-user.target

Start the service as usual:

systemctl enable wpastart.service

And you have now written your first systemd startup script.

7
  • When I execute sudo systemctl enable rc-local the following is output: pastebin.com/psFJBcjj
    – JJD
    Commented Feb 18, 2015 at 9:29
  • I've edited my answer, adding instructions on writing your own startup script, since rc.local is not working for you. Commented Feb 18, 2015 at 18:47
  • I appreciate your tutorial and would try that. To mention on Ubuntu 14.10 there is no path like /usr/lib/systemd/system, just /usr/lib/systemd. - Apart from that I have a second machine which automatically connects to the network. It also has the configuration file but in /etc/mywired.conf instead /etc/wpa_supplicant/mywired.conf. I do not remember how I wired it up there.
    – JJD
    Commented Feb 19, 2015 at 9:49
  • 1
    If your distro starts wpa_supplicant using systemd in the first place, it might be easier to modify the existing unit file. There are often provisions for options in /etc which the unit file will load automatically, as well.
    – Tom Hunt
    Commented Feb 20, 2015 at 18:36
  • @TomHunt ... which means I should do what?
    – JJD
    Commented Feb 22, 2015 at 12:15
2

Just put your command in /etc/rc.local. Make sure it's on a single line.

sudo wpa_supplicant -i eth0 -D wired -c /etc/wpa_supplicant/mywired.conf -B

I assume that your connection is stable and not dropping. Do comment if your connection drops. I'll make a script. Have to sleep now.

3
  • Can you explain why it works on another machine the way I described as I mentioned before?
    – JJD
    Commented Feb 23, 2015 at 13:46
  • sorry for the late reply. Maybe the rc.local's execute bit is disabled? try this on the defective setup: sudo chmod +x /etc/rc.local or sudo chmod 770 /etc/rc.local
    – Aloha
    Commented Feb 27, 2015 at 15:23
  • 1
    I managed to get it running as told in your initial answer. I did not have to change the file permissions. Thank you.
    – JJD
    Commented Mar 3, 2015 at 9:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .