文档在:http://iphonedevwiki.net/index.php/SSH_Over_USB
提供了homebrew的安装方式。这里给一下MacPorts下的安装方式。
1 |
sudo port install opam ocaml ocaml-camlp4 |
安装过程可能会进入opam的初始化状态,如果没有的化,可以手工执行
1 |
opam init |
慢的时候不要急着回车,中间会有需要输入y确认的选项
1 |
opam install usbmux |
gandalf的新版mapping配置用的是json,跟wiki描述的已经不一致了。
手机连上电脑,直接执行gandalf
1 2 |
$ gandalf Device 30 with serial number: 00112233445566778899aabbccddeeff00112233 connected |
编辑 mapping.json,内容如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[ { "udid": "00112233445566778899aabbccddeeff00112233", "name": "i11", "forwarding": [ { "local_port": 10022, "device_port": 22 }, { "local_port": 19988, "device_port": 9988 } ] } ] |
其中:udid与上边直接执行命令时拿到的结果须一致;name自定义;forwarding里的local_port是本地开的端口,device_port是远程的端口。
按这份配置,我可以直接使用 ssh -p 10022 root@127.0.0.1 连接到iPhone的22端口。
执行下列命令,启动gandalf。
1 |
gandalf -m mapping.json |
Set up iOS SSH over USB with MacPorts by @sskaje: https://sskaje.me/2017/07/set-up-ios-ssh-over-usb-with-macports/
Link to this post!