This guide will walk you through setting up an iOS Shortcut that interacts with the iSH
app on an iOS device. It utilizes SSH to run a script within a screen
session that prints a clickable hyperlink in the terminal. This hyperlink can trigger another iOS Shortcut, passing data back to it.
Open iSH
and run:
apk update
apk add screen openssh jq
SSH on iOS must run on a nonstandard port, I didn't really look into why. I used port 2200.
- Edit the SSH config file:
nano /etc/ssh/sshd_config
- Add or modify the following lines:
Port 2200
PermitRootLogin yes
- Modify .profile to start screen and the SSH server:
/usr/sbin/sshd &
screen -S main
then reload iSH or run
/usr/sbin/sshd
screen -S main
- Set a password for your root user:
It would probably be much more secure to make a user for this, but this is just my proof of functionality.
passwd
- Create
print_link.sh
:
nano print_link.sh
- Insert the script:
#!/bin/sh
message="Sent Back to Shortcuts"
encoded_message=$(jq -rn --arg msg "$message" '$msg|@uri')
url="shortcuts://run-shortcut?name=Cheese&input=${encoded_message}&text=[text]"
text="Click Me"
# Print the hyperlink
printf '\eP\e]8;;%s\a%s\eP\e]8;;\a\e\\\n' "$url" "$text"
- Save, exit (
Ctrl
+X
, thenY
, thenEnter
), and make the script executable:
chmod +x print_link.sh
-
Open the Shortcuts app and create a new shortcut.
-
Add actions:
- Recieve Text: from 'nowhere'
- Text: This holds the SSH command.
- Run Script Over SSH: Configure with
iSH
SSH details.
-
Fill in the details:
- Host:
127.0.0.1
- Port:
2200
- User:
root
- Password: Your iSH password
- Script: The path to
print_link.sh
. '~/print_link.sh' for me here.
- Host:
-
Add an 'If' action to check for input.
-
If input is received, show an alert; otherwise, run the SSH script.
Execute the shortcut. The hyperlink should appear in iSH
and be clickable.
I used a Shortcut named "Cheese" that both sends the original command and processes the input from the hyperlink click.
This should be able to open and pass variables back to any iOS app that supports URI.