SSH and Terminal Survival Guide

Discussion in 'iOS Jailbreak & Cydia' started by SirCharlo, Feb 8, 2010.

  1. SirCharlo

    SirCharlo New Member

    Joined:
    Aug 10, 2009
    Messages:
    38
    Likes Received:
    0
    Device:
    iPhone 4 (Black)
    SSH and Terminal Survival Guide for iPhone and iPod touch
    How to control your iPhone or iPod touch with UNIX shell commands
    The n00b way


    NOTE: for the sake of clarity, the terms "iPhone", "iPod touch", and "device", are used interchangeably in this guide, and can refer either to an iPhone or to an iPod touch.
    Commands are the same for both devices.

    Initial Setup

    For starters, you need to jailbreak your device. How to achieve this will not be covered here. There are a multitude of guides on this site and elsewhere, designed to help you in this regard.

    Once your device is jailbroken, launch Cydia, a new app on your home screen. This is the app that allows you to mod your device in any way you see fit.

    Once Cydia is fully loaded, tap on the Search tab on the bottom.

    Type, in the search field, "OpenSSH".

    Please Register or Log in to view images



    Tap on the OpenSSH package, and tap on Install on the top right.
    Tap on Confirm.

    Cydia will now install SSH on your device.

    VoilĂ  ! SSH is now installed and ready to use.

    But wait ! You need to be able to access your device from a SSH client !
    Here's how.

    Mac
    Open Spotlight and search for Terminal.

    Please Register or Log in to view images



    Launch the app.

    Please Register or Log in to view images



    To connect to your device, type (in Terminal):
    Code:
    ssh root@"your.ip.address.here"
    And press Enter.

    Terminal should now ask you for a password.

    The password is the same for all iPhones by default:
    Code:
    alpine
    Type that, press Enter, and you're in !

    Please Register or Log in to view images



    Windows
    Download this program, called PuTTY. This is what allows you to access your iPhone from your Windows machine.

    Install PuTTY, and launch it.

    Enter your iPhone's IP Address into the "Host Name (or IP Address)" field in PuTTY and hit Open. (To find your iPhone's IP address, see the first Quick tip, above.)
    Accept any authentication dialogues that pop up.

    Log in with username "root" when prompted, with the password "alpine".

    VoilĂ  !

    Congratulations ! Your computer is now connected via SSH to your iPhone. You can now begin sending commands to your device !

    Skip below to the Useful Commands section to start off right now !

    But for those of you who are zealous...

    Here's how to install Terminal locally, on your iPhone.

    The advantages of doing this are huge. For starters, you don't need a connection to the Internet to enter commands on your device.
    (I'll always remember the time I replaced the hosts file on my iPod while on the road... I had put an ad-blocking hosts file manually, but SBSettings was now non-functional with it, so I had to restore the original hosts file...)

    Open up Cydia.
    Search for MobileTerminal.
    Tap on MobileTerminal
    Tap on Install, on the top right.
    Launch it from your home screen !

    That's all there is to it, really. You now have a fully-functional Terminal on your iPhone !

    You absolutely MUST do this

    Okay, great ! You now have SSH on your iPhone, enabled and ready to fire off.

    There's one thing you absolutely have to do.

    What you basically just did, is to allow remote access to your iPhone. That, combined with the fact that all iPhones have the same passwords by default, means that anyone who knows your iPhone's IP address, can get in just as easily as you can.

    Luckily, the solution is simple !

    First, either connect to your iPhone from Terminal or PuTTY, or launch MobileTerminal (also called Terminal) on the device itself.

    Type this command:
    Code:
    su
    This tells the iPhone you want to be super-user, or root.
    If it prompts you for a password, type:
    Code:
    alpine
    You are now logged in as root on your iPhone.

    We will now change the default root password with passwd, the password-changing utility.
    Code:
    passwd
    You may have to type in your old ("alpine") password, to establish your identity.

    Now, enter a new password of your choosing, preferably a strong one with numbers, letters, and special characters.
    (Press Enter, as always)
    And re-type your new password, for confirmation.

    Now, do this:
    Code:
    passwd mobile
    You may have to type in your old ("alpine") password again.

    What we're doing is changing user "mobile"'s password, also, as "mobile" has almost as many privileges as root. This will secure the "mobile" account.

    Now, enter a new password of your choosing, preferably a strong one with numbers, letters, and special characters.
    (Press Enter, as always)
    And re-type your new password, for confirmation.

    Your iPhone is now SSH-ready, and fully secured against teen hackers who think they're cool when they use default-passwords to access other people's iPhones.

  2. Pocket_God_God

    Pocket_God_God New Member

    Joined:
    Jun 29, 2009
    Messages:
    89
    Likes Received:
    0
    Device:
    2G iPod touch
    Would you be able to explain how to shh with over usb through terminal? i know it possible but i cant remember/find how.
  3. narwal13

    narwal13 Active Member

    Joined:
    Oct 12, 2009
    Messages:
    3,070
    Likes Received:
    6
    Device:
    5G iPod touch
    YOu don't need Terminal to USB SSH. all you need is a client like iFunbox or DiskAid and a USB cable.
  4. Pocket_God_God

    Pocket_God_God New Member

    Joined:
    Jun 29, 2009
    Messages:
    89
    Likes Received:
    0
    Device:
    2G iPod touch
    My point was to not use those. I want to connect with terminal
  5. ish1tsn0w

    ish1tsn0w Member

    Joined:
    Jan 8, 2010
    Messages:
    854
    Likes Received:
    3
    Device:
    2G iPod touch
    What?Do you mean to ssh over something like winscp or putty?
    EDIT:your looking for itunnel right.
  6. Pocket_God_God

    Pocket_God_God New Member

    Joined:
    Jun 29, 2009
    Messages:
    89
    Likes Received:
    0
    Device:
    2G iPod touch
    No, osx terminal. something like that for mac
  7. studangerous

    studangerous Super Moderator Emeritus Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    5,975
    Likes Received:
    30
    Device:
    iPhone 4 (Black)
    The windows client to use for SSH and terminal is WinSCP.

    Nice guide - would be good to see some useful UNIX commands mentioned. Maybe you can write another another guide

    Please Register or Log in to view images

  8. Mr.Funman

    Mr.Funman Banned

    Joined:
    Jul 18, 2009
    Messages:
    641
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    or just download DiskAid :3
  9. studangerous

    studangerous Super Moderator Emeritus Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    5,975
    Likes Received:
    30
    Device:
    iPhone 4 (Black)
    I didn't realise DiskAid allowed UNIX command input

    Please Register or Log in to view images

  10. Mr.Funman

    Mr.Funman Banned

    Joined:
    Jul 18, 2009
    Messages:
    641
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    DiskAid is basically SSH throw USB.

    Please Register or Log in to view images

Share This Page