# Ubuntu Touch手机设置802.1x无线网络

[在Nexus 5上安装Ubuntu Touch系统](https://github.com/huataihuang/cloud-atlas-draft/tree/6f3204fffc11cf006abd394631e2598d98b415c3/develop/ubuntu_touch/install_ubuntu_touch_in_nexus_5/README.md)后发现设置802.1x网络连接存在问题。虽然我的笔记本电脑（Fedora）是可以正确访问802.1x网络，但是在Ubuntu Touch系统中，通过系统设置GUI，每次设置802.1x网络总是长时间连接无响应。

参考了[Add eduroam (or any other 802.1x) wireless network to Ubuntu Phone](https://www.danbishop.org/2015/02/21/add-eduroam-or-any-other-802-1x-wireless-network-to-ubuntu-phone/)，提示如果不能通过图形界面设置802.1x，则可以通过命令行设置。

* 准备配置文件，配置文件的名字和你需要连接的802.1x的SSID相同。例如，假设要连接的802.1x的SSID名字是`MyAP`，则编辑一个`MyAP`文件如下：

```
[connection]
id=MyAP
uuid=f789bb72-99e9-43ba-a5e4-73ffe5181940
type=802-11-wireless

[802-11-wireless]
ssid=MyAP
mode=infrastructure
security=802-11-wireless-security

[802-11-wireless-security]
key-mgmt=wpa-eap

[ipv4]
method=auto

[ipv6]
method=auto

[802-1x]
eap=peap
identity=YourName
phase2-auth=mschapv2
password=YourPassword
```

> 这里`uuid`是通过另外一个能够正常连接802.1x的Fedora主机上的配置文件获得的，根据实际情况调整。

* 启用Ubuntu Touch手机的developer模式：`System Settings` => `About` => `Developer mode`

注意：`Developer mode`要求启用手机的密码保护功能。并且这个模式对通过USB连接的主机是信任的，USB连接的主机通过`adb`命令可以对手机执行执行和更改文件，所以一定要注意安全。

* 将配置文件推送到手机

```
adb push MyAP /tmp/MyAP
```

* 然后通过`adb shell`命令将这个配置文件移动到正确目录位置：

```
adb shell -x sudo mv /tmp/MyAP /etc/NetworkManager/system-connections/
```

* `注意`：一定要正确设置配置文件的属主(`root:root`)和属性（`600`），否则会导致配置文件被忽略：

```
adb shell -x sudo chmod 600 /etc/NetworkManager/system-connections/MyAP
adb shell -x sudo chown root:root /etc/NetworkManager/system-connections/MyAP
```

* 重启手机，则可以连接到802.1x无线网络

## 参考

* [Add eduroam (or any other 802.1x) wireless network to Ubuntu Phone](https://www.danbishop.org/2015/02/21/add-eduroam-or-any-other-802-1x-wireless-network-to-ubuntu-phone/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/develop/ubuntu_touch/802.1x_wireless_network_to_ubuntu_phone.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
