HOWTO Using an iPhone With Gentoo Linux
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
Contents |
[edit] Introduction
The iPhone from Apple is a device capable of playing music with a good audio quality and a good mobile phone. In this guide you'll learn how to connect it to Amarok using openSSH on the phone and to manage the audio collection of the device.
[edit] Setup of the iPhone
First of all you have to setup the iphone to accept remote connections over SSH, so you should install (Using the installer.app on the iphone) OpenSSH.
[edit] First connection
You should connect the iphone at a wireless network so that you can access it's IP from the remote PC, I.E. To the same router of your Computer. Then on the iphone, go to:
| Code: |
|
Settings -> Wi-Fi -> YourNetwork ->
|
And read the IP address of the iphone, I.E. 192.168.1.100
now, on the PC:
| Code: |
|
pc $ ssh root@192.168.1.100
|
it will prompt for a password, enter alpine and hit enter.
[edit] Changing the root password
Ok, now you're in the iphone. First of all you should change the root password, cause it's a bit unsafe now. You shouldn't use passwd cause it's buggy, so we're going to generate the password on the pc and write it manually in the iphone.
| Code: |
|
pc $ perl -e 'print crypt("yourpassword", "/s");'
|
This will return something like /sM0V04hwjBp2 , you should copy it and paste in the /etc/master.passwd file of the iphone, removing the old one for root and mobile.
| Code: |
|
iphone # nano /etc/master.passwd
|
[edit] Setup a passwordless login
Now your iphone is safe, but you can't enter the password anytime you link it to Amarok, so we should setup a passwordless login for your PC. this is done with RSA authentication.
First of all you have to enable RSA Authentication on the iphone, so in the iphone go and edit /etc/sshd_config
| Code: |
|
iphone # nano /etc/sshd_config
|
Uncomment the following lines:
| Code: |
RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys |
Save and exit.
Now you need an rsa key pair, on the PC you can generate it using ssh-keygen, remember to not assign a password to it, or it will be useless, also you have to do this with the user that will use amarok.
| Code: |
|
pc $ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): {hit enter}
Enter passphrase (empty for no passphrase): {hit enter}
Enter same passphrase again: {hit enter}
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
e6:90:cc:41:ae:f0:98:3e:5d:66:1a:33:d0:21:72:08 user@localhost
|
The next step, is to copy it on the iphone, this is easily done (Remember to set the right ip for your iphone):
| Code: |
|
pc $ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.100
|
Now enter your password and you should be done.
Try to connect to the iphone using ssh, if it doesn't ask a password you can skip to the next paragraph, else you probably have ste's openssh, and you have to do some more steps on the iphone:
| Code: |
|
iphone $ cd ~
$ mv .ssh/authorized_keys .ssh/authorized_keys2 $ chmod 755 /var/root $ chmod 700 /var/root/.ssh $ chmod 644 /var/root/.ssh/authorized_keys |
Reboot the iphone and it should work. if it doesn't go to the trubleshooting section.
[edit] Check for the iTunes directory
The iphone can save the Media directory (With the itunes library) in /var/root or in /var/mobile, you should check now where it's and take note.
[edit] fuse and sshfs
Ok, now we have full access to the iphone, but amarok can't connect to it directly over SSH, he needs the iphone to be mounted on the pc like a normal device. It's rather easy to do, using FUSE And SSHFS which mounts a remote ssh device like a normal device.
[edit] Kernel Configurations
Fuse have to be compiled in the kernel (Or as a module autoloaded using modules.autoload.d), so you have to select it
| Linux Kernel Configuration: kernel configuration |
File systems ---> <*> Filesystem in Userspace support |
[edit] Fuse/sshfs Emerge
Next, you have to emerge Fuse and sshfs:
| Code: |
|
pc # emerge -av sys-fs/fuse sys-fs/sshfs-fuse
|
[edit] sshfs Mount
Now, we need to configure sshfs to be used by a normal user, so we need to set (as root) the right permissions to /usr/bin/fusermount
| Code: |
|
pc # chmod 4755 /usr/bin/fusermount
|
We need to make (As user) the mountpoint.
| Code: |
|
pc $ mkdir ~/iphone
|
[edit] Final Test
Finally, let's try to mount the iphone. Remember to use the right Media directory previously individuated and the right iphone ip!
| Code: |
|
pc $ sshfs root@192.168.1.100:/var/mobile/Media ~/iphone
|
[edit] Amarok Configuration
[edit] Recompile Amarok with the ipod use flag
That's easy, you just need to add the ipod use flag to /etc/make.conf or to emerge amarok using this command:
| Code: |
|
{{{2}}}
|
[edit] Setup the ipod link in the iphone
Amarok doesn't know the new iTunes directory present in the iphone, so we need to link it to the old iPod_Control, remember to use the right Media path.
| Code: |
|
iphone # ln -s /var/mobile/Media/iTunes_Control /var/mobile/Media/iPod_Control
|
[edit] Configure Amarok
We're almost done, the amarok configuration is pretty simple. Open Amarok, Go to Settings, Configure Amarok, Devices and click to "Add a device..."
Select as a plugin "Apple iPod" As name, any name, like "iPhone" As a mount point, "/home/youruser/iphone"
Now save it and go to configure, setting this as a pre-connection command:
| Code: |
|
sshfs root@192.168.1.104:/var/mobile/Media /home/youruser/iphone
|
and this as post-disconnection command:
| Code: |
|
fusermount -u /home/youruser/iphone
|
Restart Amarok and you're done.
[edit] Troubleshooting
[edit] SSH Passwordless Login, I'm Still asked for a password!
- Check your local ~/.ssh/id_rsa.pub file and compare it with the ~/.ssh/authenticated_keys file on your device. Does any entry match? If not, try the ssh-copy-id command again. Alternatively, just copy the contents of your id_rsa.pub file and paste it on a line of its own in authenticated_keys. Entries 'must' be one line only.
- Did you properly input and save the changes to /etc/sshd_conf?
- Did you reboot the iPod or iPhone after changing /etc/sshd_conf?
- If you used a tool other than ssh-copy-id, check the permissions for your SSH files. If you type the following command, it should look like this:
| Code: |
total 4 drwxr-xr-x 2 root wheel 102 Nov 21 04:25 . drwxr-xr-x 6 root wheel 306 Nov 20 00:02 .. -rw-r--r-- 1 root wheel 395 Nov 20 03:01 authorized_keys |
[edit] sshfs returns "fusermount: mount failed: Operation not permitted"!
Check if the /usr partition (The root partition if you doesn't have any /usr partition) is mounted with the "user" option in fstab, which implies "nosuid". Those options must be removed.
