I have a jailbroken iPhone. I use it to reboot my router when my wifi is going slow or messing up. But I'm lazy and I was looking for a way to automate the process. I use shortcuts that mobile terminal lets you create so you can just tap the command instead of having to type it. But is there a way I can create a script or run everything with a single command to do this for me?

Commands are as follows:


(su password)


(router password)


Can I jam all of that into one single process?

  • It will take some configuring, but it's possible. In fact, you can jam all of that into a single command, not just a script. The command would look like ssh root@ 'reboot'. You just need to set up SSH keys. Jun 30, 2014 at 17:19

1 Answer 1


The script you want would be the following:

ssh <<-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.

  1. Tap on "edit" (top right) and "+" (bottom left).
  2. Enter a name and change the type to "Regular File", then tap "Create".
  3. Tap on the file and select "Text Viewer" in the list.
  4. Tap on "Edit" and copy the above script
  5. 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.

  • Thanks for the script. I got that part done with no problems. But when I do the public/private key authentication, I follow the steps but then in the end when I try to ssh into my router, it says "permission denied (public key)". I have the public and private key saved in ~/.ssh/ on my phone. And then on ddwrt there's a text box that lets you copy and paste authorized keys. I paste the public key that my phone generated into the dd wrt box, and I uncheck "password login" I apply and reboot my router. Then I try to run ssh and get permission denied (publickey) Jul 7, 2014 at 11:55
  • Both computers need each other's public key to be able to identify. There should be some option on the router's web-interface to create a key, which should then be copied into the text file ~/.ssh/authorized_keys on your iPhone.
    – 5T41N
    Jul 22, 2014 at 15:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .