SSH Public Key Authentication

From GameOver

Jump to: navigation, search

This is a simple guide to getting SSH public key authentication to work on your iPhone/iTouch device. It assumes you already have the SSH Daemon running and of course the BSD subsystem installed, or you won't get very far!


  • Step #1 - Generate your public/private key-pair on the host machine.

If you do not specify -b 2048, a default value of 1024 will be used. This specifies the bit size of the key.

ssh-keygen -t rsa -b 2048

Example output:

Generating public/private rsa key pair.
Enter file in which to save the key (/usr/home/username/.ssh/id_rsa):
Created directory '/usr/home/username/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /usr/home/username/.ssh/id_rsa.
Your public key has been saved in /usr/home/username/.ssh/id_rsa.pub.
....


  • Step #2 - Upload the public key to the remote device(iPhone/iTouch). The public key is how the remote device authenticates against your private key.
scp ~/.ssh/id_rsa.pub root@<insert the ip of your iPhone/iTouch here>:~/authorized_keys

Example if your remote ip is 192.168.1.2:

scp ~/.ssh/id_rsa.pub root@192.168.1.2:~/authorized_keys


  • Step #3 - on your remote device. Perform the following commands.
mkdir -p ~/.ssh;
chmod 0700 ~/.ssh;
mv ~/authorized_keys ~/.ssh/authorized_keys;
chmod 600 ~/.ssh/authorized_keys;
chmod go-w /private/var/root;


  • Step #4 - Login to your remote device without typing in a password anymore and enjoy!
ssh root@<insert the ip of your iPhone/iTouch here>

Example if your remote ip is 192.168.1.2:

ssh root@192.168.1.2
Personal tools