(Move gandalf to its own page) |
No edit summary |
||
Line 138: | Line 138: | ||
On OS X, ssh-copy-id will need to be installed with <code>brew install ssh-copy-id</code>. | On OS X, ssh-copy-id will need to be installed with <code>brew install ssh-copy-id</code>. | ||
[[Category:Getting Started]] |
Revision as of 15:54, 29 September 2023
Languages: English • français • ไทย
SSH over USB using usbmuxd
You can either download a binary and run that or use a python script. The python script is a lot slower than the binary version. On Linux the python method is mostly deprecated, use the binary version provided by libimobiledevice. There is also a newer solution called gandalf.
Using binary
On Windows, ensure iTunes is installed, then download itunnel_mux_rev71.zip from Google Code. Unzip to a directory of choice.
On OS X and Linux, install usbmuxd from your package manager.
Then:
- Windows: Run
path/to/itunnel_mux.exe --iport 22 --lport 2222
- OS X/Linux:
iproxy 2222 22
Connect to localhost -p 2222
as you would over wifi.
If you have multiple devices connected, it may be useful to run multiple instances, specifying UDIDs and ports like so:
iproxy 2222 22 abcdef0123456789abcdef1234567890abcdef12 & \
iproxy 2223 22 9876543210fedcba9876543210fedcba98765432
Making iproxy run automatically in the background on OS X
- Install it with Homebrew (
brew install libimobiledevice
). - Create the file
~/Library/LaunchAgents/com.usbmux.iproxy.plist
with the contents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.usbmux.iproxy</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/iproxy</string>
<string>2222</string>
<string>22</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
- Run
launchctl load ~/Library/LaunchAgents/com.usbmux.iproxy.plist
. - You now don't have to run the iproxy binary every time you want to SSH over USB as the iproxy software is always running in the background.
If you have several devices you can create a daemon with a specific port for each one.
- Create a file in
~/Library/LaunchAgents/
but name it using the device UDID, name or an identifier of your choice (likecom.usbmux.iproxy.iPhone7,2.plist
). - Replace UDID_HERE in the following snippet with the device UDID. The label should be unique and is best to match the filename you used.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.usbmux.iproxy.iPhone7,2</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/iproxy</string>
<string>2222</string>
<string>22</string>
<string>UDID_HERE</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
- Run
launchctl load ~/Library/LaunchAgents/FILE_NAME_OF_YOUR_CHOICE
. - You now don't have to run the iproxy binary every time you want to SSH over USB as the iproxy software is always running in the background.
Using Python
Tested on OS X and Windows.
You will need to have Python installed on your system.
- Get usbmuxd source package and unpack. (Or if the linked usbmuxd package doesn't work, try libusbmuxd.)
- Go into folder python-client
chmod +x tcprelay.py
- Run
./tcprelay.py -t 22:2222
Now you can log into your device via ssh mobile@localhost -p 2222
The -t switch tells tcprelay to run threaded and allow more than one ssh over the same port.
See ./tcprelay.py --help for further options.
Using gandalf
Gandalf is a tool written in OCaml for connecting to a large amount of devices via SSH over USB.
Instructions on installation and usage can be viewed on the Gandalf page, or on the project's README
SSH over USB using the iFunBox GUI (Windows only)
This feature only exists in the Windows build of iFunBox.
- Get the latest Windows build of iFunBox and install it.
- Click on "Quick Toolbox," then "USB Tunnel."
- Assign ports as you see fit.
SSH over USB using iPhoneTunnel Menu Bar Application (macOS Intel only)
- Turn Tunnel On
- Tools -> SSH
Theos usage
Export the following variables in your shell in order to deploy builds to the connected device:
export THEOS_DEVICE_IP=localhost
export THEOS_DEVICE_PORT=2222
SSH without password
Run the following commands one time and you will not be asked to type your password again.
You must create an SSH key with ssh-keygen
if you have not created one. A passphrase isn’t required but still recommended. You can use ssh-agent
as described here to keep the passphrase in memory and not be prompted for it constantly.
Then run the following command:
ssh-copy-id root@DEVICE_IP
On OS X, ssh-copy-id will need to be installed with brew install ssh-copy-id
.