The script you want would be the following:
#!/bin/bash
su
ssh 192.168.1.1 <<-EOF
reboot
exit
EOF
If you can ssh into your iPhone from a computer, do so. Once you're logged in, create a new text file using nano ~/script
(install nano from cydia if it isn't already) and paste the above script. Then hit ^X
(control-X) and Y
to save the script. The script is in your home directory (~
) for quick access. Now, set the proper permissions to be able to execute the script:
chmod 755 script
Now you can open MobileTerminal on the iPhone and type ./script, which will execute it.
If you have to do it locally, the easiest way is probably using iFile: open it and change to the home folder using the button at the bottom of the screen.
- Tap on "edit" (top right) and "+" (bottom left).
- Enter a name and change the type to "Regular File", then tap "Create".
- Tap on the file and select "Text Viewer" in the list.
- Tap on "Edit" and copy the above script
- Tap "Save" and "Done" and go to MobileTerminal to execute it (no need to set permissions, iFile did it)
Final note: you might want to set up automatic login using keys: http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/
That way, you only have to launch the script, no password-typing required.
ssh root@192.168.1.1 'reboot'
. You just need to set up SSH keys.