个人工具

“UbuntuHelp:PortableDevices/iPhone”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/PortableDevices/iPhone}}
 
{{From|https://help.ubuntu.com/community/PortableDevices/iPhone}}
 
{{Languages|UbuntuHelp:PortableDevices/iPhone}}
 
{{Languages|UbuntuHelp:PortableDevices/iPhone}}
== Setup iPod Touch or iPhone ==
+
#title Using an iPhone or iPod Touch with Ubuntu
'''Disclaimer:''' Making unsupported changes to your iPhone / iPod Touch could result in data loss and possibly void your warranty.  Follow this howto with care.
+
== Syncing Music ==
=== Determine your Firmware Version ===
+
Amarok and gtkpod can wirelessly sync music with iPod Touch and iPhone, including adding, editing and playing songs and playlists.
Follow this wiki page for information on how to properly jailbreak.
+
This guide requires Ubuntu 7.10 or 8.04.
* [http://www.touchdev.net/wiki/How_to_Escape_Jail]
+
'''Warning:''' While this guide works fine for most users, making unsupported changes to your iPhone or iPod Touch is done at your own risk and could result in data loss and possibly void your warranty.  Follow this guide with care.
It has directions for both 1.1.1 and 1.1.2 firmwares.  Note that if you want to keep firmware 1.1.2, you may need a Mac or Windows machine to assist you.
+
=== Set up the iPhone or iPod ===
=== OpenSSH ===
+
On your iPhone or iPod Touch:
Once you've jailbroken your phone you'll need to install OpenSSH.
+
Your iPhone or iPod Touch must be "jailbroken" so you can run Installer. Follow these [http://www.touchdev.net/wiki/How_to_Escape_Jail instructions on jailbreaking] to properly jailbreak - note you might need a Mac or Windows to do this.
* Navigate to the Installer.app icon that is now on your springboard home screen.
+
<ol><li>Click '''Settings''' → '''General''' and set '''Auto-lock''' to '''Never'''.  This will ensure the iPhone keeps the WiFi connection open.
* Scroll down and click on ''System''
+
</li><li>Click '''Settings''' → '''WiFi''' and select your WiFi network. Click the '''Static''' button and change the '''IP Address''' to an address that's outside the dynamically assigned range of your network. This will ensure your iPhone is always contactable at the same address for syncing.
* Click on ''OpenSSH''
+
</li><li>Open '''Installer'''.
* Click on ''Install''
+
</li><li>Click '''All Packages''' → '''BSD Subsystem''' → '''Install'''
=== BSD Utils ===
+
</li><li>Click on '''All Packages''' → '''OpenSSH''' → '''Install'''.</li></ol>
Also, after you've jailbroken your phone you'll need the BSD utility set.
+
 
* Navigate to the Installer.app icon on your springboard home screen.
+
=== Set up Ubuntu ===
* Scroll down and click on ''System''
+
In Ubuntu:
* Click on ''BSD Subsystem''
+
A third party source provides the '''ipod convenience''' package needed to properly mount and unmount an iPhone or iPod Touch, and for gtkpod users, a newer gtkpod is required for the iPhone and iPod Touch.
* Click on ''Install''
+
<ol><li>Click '''System''' → '''Administration''' → '''Synaptic Package Manager''' (You can skip this step on Ubuntu 8.04 as the relevant packages have been added in the Universe repository)</li></ol>
== Set up Ubuntu ==
+
 
== Passwordless Login ==
+
Once Synaptic starts, click '''Settings''' → '''Repositories''' → '''Third Party Software'''. Click '''Add''' and use '''deb http://ppa.launchpad.net/ipod-touch/ubuntu gutsy main''' as the APT line. (this source should have a key file to avoid the prompt to install without authentication).
When you mount your device (by running sshfs), you're required to supply your password to login. This makes it impossible for applications such as Amarok to perform the mount on demand - as in, connect - since it doesn't take the password prompt into consideration. You need a passwordless login for that!
+
<ol><li>Click '''Reload'''
First, you want to generate a private and a public passkey, if you don't have one already. Enter this command on your local machine (not in an ssh session to your device), accept the default location, and don't enter any passphrase.
+
</li><li>Before installing newer packages, make sure to first uninstall '''libgpod'''.
 +
</li><li>Install the '''ipod-convenience''' package, as well as either '''amarok''' or '''gtkpod''' (or both if you like). When asked, enter the IP address of your iPod Touch or iPhone that you selected earlier. When asked for a folder to mount your iPod Touch or iPhone, either leave the default of '''/media/ipod''' or another folder if you prefer - just remember to use that folder name for rest of this guide. The package will make the folder for you.
 +
</li><li>Plug in your iPod Touch or iPhone via USB. This is '''REQUIRED''' when you run the next steps for the first time, as the USB connection is used to generate a hash required by the iTunes Database (if this fails to generate properly, see the troubleshooting section below). An added benefit is this also makes sure that your device won't turn the wifi into low power mode, breaking the transfer connection.
 +
</li><li>When done, click '''Applications''' '''Accessories''' → '''Terminal'''. To mount your device, run: <pre><nowiki>
 +
iphone-mount
 +
or
 +
ipod-touch-mount
 +
</nowiki></pre> When prompted, enter your iPhone or iPod Touch's root password - by default, '''dottie''' in firmware 1.0 and '''alpine''' in 1.1, 1.2 and 1.4 (can someone confirm 1.3?).
 +
</li><li>Unmount your device, by running: <pre><nowiki>
 +
iphone-umount
 +
or
 +
ipod-touch-umount
 +
</nowiki></pre></li></ol>
 +
 
 +
==== Amarok ====
 +
<ol><li>Click '''Applications''' → '''Sound and Video''' → '''Amarok'''</li></ol>
 +
 
 +
When you first open up Amarok:
 +
<ol><li>Click '''Settings''' → '''Configure Amarok'''.
 +
</li><li>Choose '''Media Devices'''.
 +
</li><li>Hit '''Add Device'''.
 +
</li><li>Select '''Apple iPod Media Device''' for the plugin type.
 +
</li><li>Point it at your mount point, '''/media/ipod'''.
 +
</li><li>Back in the main app, click the blue cog icon called '''Configure Device''' just above the iPhone or iPod Touch. For '''Pre-Connect Command''', add '''iphone-mount''' (or '''ipod-touch-mount'''), for the '''Post-Disconnect Command''', add '''iphone-umount''' (or '''ipod-touch-umount''')
 +
</li><li>In Devices, click '''Connect'''. After entering your password, your iPhone or iPod touch should now appear in Amarok.
 +
</li><li>Once connected, click on the double arrows on the right hand side of the '''Connect''', '''Disconnect''', and '''Transfer''' buttons. A list of options opens up, one of which is '''iPod'''.  Choose '''iPod''' > '''Set iPod Model''' > '''Mobile Phones''' > '''iPhone''' (or your specific iPod Touch model).</li></ol>
 +
 
 +
==== gtkpod ====
 +
<ol><li>Check the version of gtkpod '''Help''' → '''About''' and kiss your tunes goodby if it's 0.99.10 (compile 0.99.12 from gtkpod.org; ask me how I know). The database corruption from 0.99.10 can be fixed so tune loss is temporary - just re-write with 0.9.12.
 +
</li><li>Click '''Applications''' → '''Sound and Video''' → '''gtkpod'''
 +
</li><li>When you first open gtkpod you may receive some errors.  Simply click OK to proceed.  Your iPhone or iPod Touch should now appear in gtkpod.  If it doesn't, you can manually add it's mount point in the options dialog.
 +
</li><li>Right-click on the iPhone or iPod, and choose '''Edit iPod properties''' (or choose '''Edit''' > '''Edit repositories/iPod options''') and change the iPod model to reflect your iPhone or iPod Touch.</li></ol>
 +
 
 +
Simply add music to the iPhone or iPod Touch like you would any other iPod and '''Save Changes''' when done.
 +
'''''NOTE:''''' The iPod Touch seems to be supported in 'read only' mode only. Uploading a test photo to the Touch seemed to work, but then the album ended up empty/damaged ('no photos') when trying to access it from the Touch itself. I have not tried uploading music yet, but I expect the result to be the same. Also, the amount of free GB's shown is wrong (1000 GB Free) for the iPod Touch 16GB.
 +
=== Extras ===
 +
==== Passwordless Access ====
 +
In order for programs like Amarok to connect to your iPhone via SSH without asking for a password, you'll can set up key based logins. You can skip this step if you're happy typing your password each time.
 +
<ol><li>Make a private and a public key, if you don't have one already. Run the following command in Ubuntu, and when prompted, accept the default location, and don't enter any passphrase.</li></ol>
 +
 
 
<pre><nowiki>
 
<pre><nowiki>
 
ssh-keygen -t rsa
 
ssh-keygen -t rsa
 
</nowiki></pre>
 
</nowiki></pre>
 
This will create a directory called .ssh in your home directory, and place three files in there: id_rsa, id_rsa.pub, and known_hosts. id_rsa is your private keyfile, and id_rsa.pub is your public one. You want your device to have the public key so you can authenticate towards it with your private one. After entering this next command, if it asks if you want to accept the untrusted device as a trusted host, do so.
 
This will create a directory called .ssh in your home directory, and place three files in there: id_rsa, id_rsa.pub, and known_hosts. id_rsa is your private keyfile, and id_rsa.pub is your public one. You want your device to have the public key so you can authenticate towards it with your private one. After entering this next command, if it asks if you want to accept the untrusted device as a trusted host, do so.
 +
<ol><li>Install your public key to the device:</li></ol>
 +
 
<pre><nowiki>
 
<pre><nowiki>
 
ssh-copy-id -i ~/.ssh/id_rsa.pub root@<device ip>
 
ssh-copy-id -i ~/.ssh/id_rsa.pub root@<device ip>
 
</nowiki></pre>
 
</nowiki></pre>
This will copy your public keyfile and place it into /var/root/.ssh/authenticated_keys on your device, creating it if necessary. Now log back in.
+
<ol><li>Log into your iPhone again:</li></ol>
 +
 
 
<pre><nowiki>
 
<pre><nowiki>
 
ssh root@<device ip>
 
ssh root@<device ip>
 
</nowiki></pre>
 
</nowiki></pre>
Don't worry if it asks for your password; at this point, it still should. Feel free to view the contents in the authenticated_keys file and compare to your own id_rsa.pub file, if you wish. Don't log out yet.
+
The SSH service will still prompt for a password, as public key auth is not yet configured. The default password for 1.1.0 phones is 'dottie', and 'alpine' for 1.1.1 and 1.1.2 phones.
 +
<ol><li>Change the password. This is important for security. You'll be logging in via your key anyway, but make it something you'll remember.</li></ol>
 +
 
 +
*NOTE: On firmware 1.1.3, BSD Subsystem maintainers highly recommend against using the "passwd" command until a stability bug is fixed. Until then, you can use
 
<pre><nowiki>
 
<pre><nowiki>
chmod 0755 ~ ~/.ssh
+
perl -e 'print crypt("yourpasswordhere", "/s");'
chmod 0644 ~/.ssh/*
+
 
</nowiki></pre>
 
</nowiki></pre>
Do this while still logged in. This will set up the permissions the ssh daemon requires to read root's authenticated keys. Next we'll configure some settings.
+
and replace the password hashes for the users 'root' and 'mobile' in /etc/master.passwd on your device.
 
<pre><nowiki>
 
<pre><nowiki>
pico /etc/sshd_config
+
passwd
 
</nowiki></pre>
 
</nowiki></pre>
If you aren't familiar with pico, now's a good opportunity to get to know it better. nano is a clone of pico, so if you're used to the former, you'll quickly find your legs in the latter. If you're never heard of either, no worries, keep reading.
+
*NOTE: The following steps do NOT apply to Ste's OpenSSH package, which is probably the most common one now. In order to get passwordless login working with Ste's package, rename your .ssh/authorized_keys file on your device to .ssh/authorized_keys2 and proceed straight to adjusting the permissions as described below ("if all else fails"). Full instructions can be found here: [http://blog.psmxy.org/pkg-info/openssh/]
Scroll down to the segment beginning with '#RSAAuthentication', and set it up as follows:
+
If you are not using Ste's OpenSSH package, follow these instructions:
 +
<ol><li>We'll need to enable public key logins via SSH. Edit /etc/sshd_config:</li></ol>
 +
 
 +
<pre><nowiki>
 +
nano /etc/sshd_config
 +
</nowiki></pre>
 +
<ol><li>In your chosen editor, scroll down to the segment beginning with '#RSAAuthentication', and set it up as follows:</li></ol>
 +
 
 
<pre><nowiki>
 
<pre><nowiki>
 
RSAAuthentication yes
 
RSAAuthentication yes
 
PubkeyAuthentication yes
 
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
+
AuthorizedKeysFile .ssh/authorized_keys
 
</nowiki></pre>
 
</nowiki></pre>
Be sure to remove any hashmarks (#) at the beginning of those three lines, or else they won't be read.
+
Remove any hashes (#) at the beginning of these three lines.
Hit Ctrl+O to save, and Ctrl+X to exit.
+
<ol><li>Hit Ctrl+X to exit, and save your changes.
At this point you should be finished. Reboot your device.
+
</li><li>At this point you should be finished. Reboot your device.</li></ol>
 +
 
 
<pre><nowiki>
 
<pre><nowiki>
 
reboot
 
reboot
 
</nowiki></pre>
 
</nowiki></pre>
If you're confident you've given it time enough to start up, try logging back in. Hopefully, without supplying any password.
+
<ol><li>If you're confident you've given it time enough to start up, try logging back in. This time, you should be logged in without being asked for a password.</li></ol>
 +
 
 
<pre><nowiki>
 
<pre><nowiki>
 
ssh root@<device ip>
 
ssh root@<device ip>
 
</nowiki></pre>
 
</nowiki></pre>
If it still doesn't work:
+
If you're 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.
+
* 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 properly input and save the changes to /etc/sshd_conf?
* And you did reboot it, right?
+
* Did you reboot the iPod or iPhone after changing /etc/sshd_conf?
* Check those permissions we changed on certain directories on the device. If you type the following command, it should look like this:
+
* 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:
 
<pre><nowiki>
 
<pre><nowiki>
 
# ls -al ~/.ssh
 
# ls -al ~/.ssh
第72行: 第125行:
 
-rw-r--r-- 1 root wheel 395 Nov 20 03:01 authorized_keys
 
-rw-r--r-- 1 root wheel 395 Nov 20 03:01 authorized_keys
 
</nowiki></pre>
 
</nowiki></pre>
=== ipod-convenience (Automatic Method) ===
+
* If all else fails, try resetting the permissions on the iPod or iPhone's SSH files manually:
For Gutsy users, an application is stored on a PPA (personal package archive) that can be used for properly mounting and unmounting an iPhone or iPod touch so that artwork will work.
+
 
<pre><nowiki>
 
<pre><nowiki>
deb http://ppa.launchpad.net/ipod-touch/ubuntu gutsy main
+
chmod 755 /var/root
 +
chmod 700 /var/root/.ssh
 +
chmod 644 /var/root/.ssh/authorized_keys
 
</nowiki></pre>
 
</nowiki></pre>
Add that repository to your /etc/apt/sources.list.
+
=== Retrieving and setting the Firewire GUID (FirewireGuid) ===
Update your apt database
+
When you issue iphone-mount or ipod-touch-mount for the first time, the program silently attempts to generate this value using a USB connection. If you have never connected your device via USB before and try to mount it via WiFi for the first time, this step is missed and you end up with a database that your device refuses to read. This is (in nearly all cases) because the Firewire GUID (FirewireGuid) that the iPhone/iPod Touch specifically use to hash their database is either missing or invalid.
<pre><nowiki>
+
To fix this manually:
sudo apt-get update && sudo apt-get upgrade
+
* Plug your iPhone/iPod device into your Ubuntu machine via USB
 +
* In Ubuntu, run '''Applications''' → '''Accessories''' → '''Terminal'''
 +
* Issue iphone-mount or ipod-touch-mount (depending on your device) in the terminal
 +
* Path to /media/ipod/iPod_Control/Device ("cd /media/ipod/iPod_Control/Device", assuming you used /media/ipod for the mount location)
 +
* Run "sudo lsusb -v -d 05ac: | grep iSerial | awk '{print $3}' | cut -b1-16  | xargs printf "FirewireGuid: 0x%sn" > SysInfo" (Found [http://www.fredemmott.co.uk/blog_121 here]).
 +
* In your media application of choice, transfer a new song and/or sync your iPod. Depending on what media application you use, you might have to re-transfer all songs.
 +
* Reboot your device
 +
You may also get the GUID directly from the device by executing:
 +
<pre><nowiki> /usr/sbin/ioreg  -n IOIpodUSBDevice  -w 0 | grep DeviceConfiguration | cut -d '"' -f 44 | cut -c 1-16
 
</nowiki></pre>
 
</nowiki></pre>
Install ipod-convenience
+
If all goes well, your music should now be recognized on the device!
<pre><nowiki>
+
=== Alternative solution with MNPlight ===
sudo apt-get install ipod-convenience
+
* Add the http://movenplay.gforge.inria.fr/iphone link to your Ipod Touch or Iphone installer.
</nowiki></pre>
+
* Install MNPlight.
To mount your device use this command:
+
* For Ipod Touch you need to set the "FirewareGuid" of device (see previous section).
<pre><nowiki>
+
* Set the Fireware GUID in '''MNPlight'''→'''Preferences'''.
iphone-mount
+
'''Warning:''' Without this step MNPlight will corrupt your music database!
</nowiki></pre>
+
* Copy your music in to '''/var/root/Media/MNPlight/Music''' folder of your Iphone/Ipod Touch and import it by '''MNPlight'''→'''Playlists'''→'''Import songs from directory'''
To unmount your device, use this command:
+
== Troubleshooting ==
<pre><nowiki>
+
=== Programs fail to sync, stating the device is not present ===
iphone-umount
+
A "gotcha" currently exists if you accidentally "sudo" the iphone-mount or ipod-touch-mount step. Doing so will create a template file set at your mount location (eg. /media/ipod) and subsequent mount operations will fail uncleanly. If this occurs, verify the device is indeed not mounted, clean out /media/ipod, verify the permissions are correct, and mount again as your normal user.
</nowiki></pre>
+
=== Music appears in the Ubuntu media player, but is not playable or does not appear on the iPhone/iPod device ===
=== Manual Method ===
+
The most frustrating "gotcha" is failing to have a correct '''FirewireGuid''' written onto your device. This is normally generated when the device is attached for the first time, assuming you had the device plugged in via USB at the time. If this hash is incorrect or not present, iTunes will refuse to load the database.
Note: this method is a bit more convoluted, time consuming and prone to errors.
+
If the music still doesn't appear on your iPhone/iPod, you might have to restart the music playing programme. Select music and hold down the main button for a few seconds. You'll be dumped back to the main screen.
==== SSHFS ====
+
Please see the section above on setting the Firewire GUID.
This is what lets you mount ssh filesystems, we'll use this to mount our iphone.
+
=== Firmware 1.1.3 ===
Install sshfs:  <pre><nowiki>
+
If you soft-upgraded to firmware version 1.1.3 with the Official iPhone Dev package (this does not seem to affect iPhones updated or restored firmware 1.1.3 iPhone jailbroken with ziPhone), there may be issues with getting in via SSH (Connection refused, timeout, etc). Uninstall the OpenSSH package, reinstall the BSD Subsystem package, then reinstall OpenSSH.
sudo apt-get install sshfs
+
Try logging back in as root, with the password as whatever you set it to in a previous firmware version, or the default, which is still 'alpine'.  
</nowiki></pre>
+
Once you have logged in, changes need to be made before you can mount everything properly with the ipod-convenience script. User-run programs now run as user "mobile" instead of root, and media has been moved from /private/var/root/Media to /private/var/mobile/Media. The ipod-convenience script expects them to be in the former, so a link needs to be made to point to the new Media folder. Issue
Create a mountpoint:   <pre><nowiki>
+
<pre><nowiki>  
sudo mkdir /media/ipod
+
ln -s /private/var/mobile/Media /private/var/root/Media
</nowiki></pre>
+
Change read/write access to it: <pre><nowiki>
+
sudo chown <username> /media/ipod
+
</nowiki></pre>
+
Add your user to the "fuse" user group:  <pre><nowiki>
+
sudo adduser <username> fuse
+
</nowiki></pre>
+
Log out and back in again (this is necessary for your user group to be taken into account).
+
=== Determine your Firewire GUID ===
+
The iPod Touch requires you to create a file that is used when generating the iTunesDB and ArtworkDB which store the information of which files are on the iPod. This is not necessary for the iPhone.
+
==== Find Firewire GUID ====
+
Plug in your iPod Touch or iPhone and run this command:
+
<pre><nowiki>
+
sudo lsusb -v | grep -i Serial
+
</nowiki></pre>
+
You will receive an output similar to this:
+
<pre><nowiki>
+
  iSerial                3 8089e2ce5193625c38813ec10fad4032ec839c02
+
 
+
  iSerial                1 0000:00:1d.7
+
 
+
  iSerial                1 0000:00:1d.2
+
 
+
  iSerial                1 0000:00:1d.1
+
 
+
  iSerial                1 0000:00:1d.0
+
 
+
</nowiki></pre>
+
Now what you are interested in is the first 16 characters of that really long string.  This is the Firewire GUID.
+
==== Place Firewire GUID in iPhone or iPod Touch ====
+
Go to the wifi settings on your iphone. tap the blue arrow next to your SSID, so that you can see your iphone's IP address. Note it down somewhere.
+
SSH into your device.
+
The first time you do this it may take up to 30 seconds to generate the SSH keys. When prompted, the default password is ''dottie'' in pre firmware version 1.1.1 and ''alpine'' in 1.1.1.  With firmware 1.1.2, you will generally have set your root address already.
+
<pre><nowiki>
+
ssh root@<your device's ip address>
+
</nowiki></pre>
+
Create the directory structure if necessary
+
<pre><nowiki>
+
mkdir -p /var/root/Media/iTunes_Control/Device
+
</nowiki></pre>
+
Create the file for the GUID.  Be sure to replace the 16 character string you found with the one after the 0x in this example.
+
<pre><nowiki>
+
echo "FirewireGuid: 0x8089e2ce5193625c" > /var/root/Media/iTunes_Control/Device/SysInfo
+
</nowiki></pre>
+
==== Symbolic Linking ====
+
*Go to your general settings and set "auto-lock" to "never".  The iphone closes the wifi connection when it's locked.
+
*SSH back into the iPod.
+
*If you didn't change your password on your iphone it is highly recommended that you do it now with the <code><nowiki>passwd</nowiki></code> command.
+
Move to where the iTunes library is:  <pre><nowiki>
+
cd /var/root/Media
+
</nowiki></pre>
+
Make a symbolic link to this directory from within itself (weird, but necesserary):  <pre><nowiki>
+
ln -s . iTunes
+
</nowiki></pre>
+
Make another symbolic link to the iTunes_Control directory called iPod_Control:  <pre><nowiki>
+
ln -s iTunes_Control iPod_Control
+
</nowiki></pre>
+
Get out of the iphone. <pre><nowiki>
+
exit
+
</nowiki></pre>
+
==== Mount iPhone ====
+
In ubuntu now, we need to actually perform the mount! <pre><nowiki>
+
sshfs root@<iphone's ip address>:/var/root/Media/ /media/ipod/
+
</nowiki></pre>
+
=== Amarok ===
+
Amarok seems to manage the iPod touch and iPhone much nicer than gtkpod, but this is a matter of preference.
+
The version of gtkpod in the archives does not properly handle newer devices.  There is a version on this PPA (personal package archive) that does.
+
<pre><nowiki>
+
deb http://ppa.launchpad.net/ipod-touch/ubuntu gutsy main
+
</nowiki></pre>
+
Add that repository to your /etc/apt/sources.list.
+
Update your apt database
+
<pre><nowiki>
+
sudo apt-get update && sudo apt-get upgrade
+
</nowiki></pre>
+
If you don't have gtkpod, install it now: 
+
<pre><nowiki>
+
sudo apt-get install amarok ipodslave
+
</nowiki></pre>
+
When you first open up Amarok,
+
*Click Settings->Configure Amarok.
+
*Choose Media Devices.
+
*Hit Add Device.
+
*Select "Apple iPod Media Device" for the plugin type.
+
*Point it at your mount point, /media/ipod.
+
You should now be able to Connect & Transfer with no problems.  Be *sure* to disconnect when done so that the database is properly written out.
+
==== Automatic Mounting ====
+
If you have configured your iPhone or iPod Touch for passwordless login via ssh, you can do this.  Otherwise do that first.
+
For the Pre-Connect Command in the settings, add this:
+
<pre><nowiki>
+
sshfs root@ipod:/var/root/Media /media/ipod -o uid=1000
+
</nowiki></pre>
+
For the Post-Disconnect Command, add this:
+
<pre><nowiki>
+
fusermount /media/ipod -u
+
 
</nowiki></pre>
 
</nowiki></pre>
=== gtkpod ===
+
while logged into the iPhone or ipod touch via SSH.  
The version of gtkpod in the archives does not properly handle newer devices. There is a version on this PPA (personal package archive) that does.
+
An alternative solution is to modify the ipod-convenience script (no need to create the link on the iphone/ipod touch):
 
<pre><nowiki>
 
<pre><nowiki>
deb http://ppa.launchpad.net/ipod-touch/ubuntu gutsy main
+
cd /usr/share/ipod-convenience/
 +
sudo cp mount-umount mount-umount.bak
 +
sudo gedit mount-umount
 
</nowiki></pre>
 
</nowiki></pre>
Add that repository to your /etc/apt/sources.list.
+
and at line 62 modify:
Update your apt database
+
 
<pre><nowiki>
 
<pre><nowiki>
sudo apt-get update && sudo apt-get upgrade
+
#Mount our Music Directory
 +
sshfs root@$IPADDRESS:/var/root/Media $MOUNTPOINT/ -o workaround=rename
 
</nowiki></pre>
 
</nowiki></pre>
If you don't have gtkpod, install it now: 
+
into
 
<pre><nowiki>
 
<pre><nowiki>
sudo apt-get install gtkpod
+
#Mount our Music Directory
 +
sshfs root@$IPADDRESS:/var/mobile/Media $MOUNTPOINT/ -o workaround=rename
 
</nowiki></pre>
 
</nowiki></pre>
When you first open gtkpod you may receive some errors.  Simply click OK to proceed.  Your iPhone or iPod Touch should now appear in gtkpod.  If it doesn't, you can manually add it's mount point in the options dialog.
+
=== No Coverart with Amarok ===
Simply add music to the iPhone or iPod Touch like you would any other iPod and ''Save Changes'' when done.
+
If you find that after syncing your iPhone with Amarok the coverart is missing it is very likely that you are using the wrong version of libgpod. Amarok depends on libgpod and the Ubuntu repositories version installs libgpod v2 instead of the needed libgpod v3. Workaround:
If you aren't using ipod-convenience, you'll need to kill the iPod app for the track changes to take affect. To do this:
+
* Uninstall libgpod v2. This will also uninstall Amarok
*Tap the iPod app then hold down the home key for 5+ seconds until you are returned to the springboard.
+
* Open Synaptic and uncheck all the repositories but http://ppa.launchpad.net/ipod-touch/ubuntu
*Open the iPod app and your new music should now appear
+
* Refresh
 +
* Install libgpod v3 and Amarok
 +
* Re-check all the previously unchecked repositories
 +
* Start Amarok and connect to your iPhone
 +
* Make sure that the correct kind of iPod is selected in Amarok (under iPod -> iPod Models -> Mobile Phones)
 +
* Click on Refresh Graphics and on Disconnect (this might take a while)
 +
You should have your Coverart correctly loaded on the iPhone afterwards.
 +
----
 +
[[category:CategoryCleanup]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2008年4月23日 (三) 11:53的版本

  1. title Using an iPhone or iPod Touch with Ubuntu

Syncing Music

Amarok and gtkpod can wirelessly sync music with iPod Touch and iPhone, including adding, editing and playing songs and playlists. This guide requires Ubuntu 7.10 or 8.04. Warning: While this guide works fine for most users, making unsupported changes to your iPhone or iPod Touch is done at your own risk and could result in data loss and possibly void your warranty. Follow this guide with care.

Set up the iPhone or iPod

On your iPhone or iPod Touch: Your iPhone or iPod Touch must be "jailbroken" so you can run Installer. Follow these instructions on jailbreaking to properly jailbreak - note you might need a Mac or Windows to do this.

  1. Click SettingsGeneral and set Auto-lock to Never. This will ensure the iPhone keeps the WiFi connection open.
  2. Click SettingsWiFi and select your WiFi network. Click the Static button and change the IP Address to an address that's outside the dynamically assigned range of your network. This will ensure your iPhone is always contactable at the same address for syncing.
  3. Open Installer.
  4. Click All PackagesBSD SubsystemInstall
  5. Click on All PackagesOpenSSHInstall.

Set up Ubuntu

In Ubuntu: A third party source provides the ipod convenience package needed to properly mount and unmount an iPhone or iPod Touch, and for gtkpod users, a newer gtkpod is required for the iPhone and iPod Touch.

  1. Click SystemAdministrationSynaptic Package Manager (You can skip this step on Ubuntu 8.04 as the relevant packages have been added in the Universe repository)

Once Synaptic starts, click SettingsRepositoriesThird Party Software. Click Add and use deb http://ppa.launchpad.net/ipod-touch/ubuntu gutsy main as the APT line. (this source should have a key file to avoid the prompt to install without authentication).

  1. Click Reload
  2. Before installing newer packages, make sure to first uninstall libgpod.
  3. Install the ipod-convenience package, as well as either amarok or gtkpod (or both if you like). When asked, enter the IP address of your iPod Touch or iPhone that you selected earlier. When asked for a folder to mount your iPod Touch or iPhone, either leave the default of /media/ipod or another folder if you prefer - just remember to use that folder name for rest of this guide. The package will make the folder for you.
  4. Plug in your iPod Touch or iPhone via USB. This is REQUIRED when you run the next steps for the first time, as the USB connection is used to generate a hash required by the iTunes Database (if this fails to generate properly, see the troubleshooting section below). An added benefit is this also makes sure that your device won't turn the wifi into low power mode, breaking the transfer connection.
  5. When done, click ApplicationsAccessoriesTerminal. To mount your device, run:
    iphone-mount
    or
    ipod-touch-mount
    
    When prompted, enter your iPhone or iPod Touch's root password - by default, dottie in firmware 1.0 and alpine in 1.1, 1.2 and 1.4 (can someone confirm 1.3?).
  6. Unmount your device, by running:
    iphone-umount
    or
    ipod-touch-umount
    

Amarok

  1. Click ApplicationsSound and VideoAmarok

When you first open up Amarok:

  1. Click SettingsConfigure Amarok.
  2. Choose Media Devices.
  3. Hit Add Device.
  4. Select Apple iPod Media Device for the plugin type.
  5. Point it at your mount point, /media/ipod.
  6. Back in the main app, click the blue cog icon called Configure Device just above the iPhone or iPod Touch. For Pre-Connect Command, add iphone-mount (or ipod-touch-mount), for the Post-Disconnect Command, add iphone-umount (or ipod-touch-umount)
  7. In Devices, click Connect. After entering your password, your iPhone or iPod touch should now appear in Amarok.
  8. Once connected, click on the double arrows on the right hand side of the Connect, Disconnect, and Transfer buttons. A list of options opens up, one of which is iPod. Choose iPod > Set iPod Model > Mobile Phones > iPhone (or your specific iPod Touch model).

gtkpod

  1. Check the version of gtkpod HelpAbout and kiss your tunes goodby if it's 0.99.10 (compile 0.99.12 from gtkpod.org; ask me how I know). The database corruption from 0.99.10 can be fixed so tune loss is temporary - just re-write with 0.9.12.
  2. Click ApplicationsSound and Videogtkpod
  3. When you first open gtkpod you may receive some errors. Simply click OK to proceed. Your iPhone or iPod Touch should now appear in gtkpod. If it doesn't, you can manually add it's mount point in the options dialog.
  4. Right-click on the iPhone or iPod, and choose Edit iPod properties (or choose Edit > Edit repositories/iPod options) and change the iPod model to reflect your iPhone or iPod Touch.

Simply add music to the iPhone or iPod Touch like you would any other iPod and Save Changes when done. NOTE: The iPod Touch seems to be supported in 'read only' mode only. Uploading a test photo to the Touch seemed to work, but then the album ended up empty/damaged ('no photos') when trying to access it from the Touch itself. I have not tried uploading music yet, but I expect the result to be the same. Also, the amount of free GB's shown is wrong (1000 GB Free) for the iPod Touch 16GB.

Extras

Passwordless Access

In order for programs like Amarok to connect to your iPhone via SSH without asking for a password, you'll can set up key based logins. You can skip this step if you're happy typing your password each time.

  1. Make a private and a public key, if you don't have one already. Run the following command in Ubuntu, and when prompted, accept the default location, and don't enter any passphrase.
ssh-keygen -t rsa

This will create a directory called .ssh in your home directory, and place three files in there: id_rsa, id_rsa.pub, and known_hosts. id_rsa is your private keyfile, and id_rsa.pub is your public one. You want your device to have the public key so you can authenticate towards it with your private one. After entering this next command, if it asks if you want to accept the untrusted device as a trusted host, do so.

  1. Install your public key to the device:
ssh-copy-id -i ~/.ssh/id_rsa.pub root@<device ip>
  1. Log into your iPhone again:
ssh root@<device ip>

The SSH service will still prompt for a password, as public key auth is not yet configured. The default password for 1.1.0 phones is 'dottie', and 'alpine' for 1.1.1 and 1.1.2 phones.

  1. Change the password. This is important for security. You'll be logging in via your key anyway, but make it something you'll remember.
  • NOTE: On firmware 1.1.3, BSD Subsystem maintainers highly recommend against using the "passwd" command until a stability bug is fixed. Until then, you can use
perl -e 'print crypt("yourpasswordhere", "/s");'

and replace the password hashes for the users 'root' and 'mobile' in /etc/master.passwd on your device.

passwd
  • NOTE: The following steps do NOT apply to Ste's OpenSSH package, which is probably the most common one now. In order to get passwordless login working with Ste's package, rename your .ssh/authorized_keys file on your device to .ssh/authorized_keys2 and proceed straight to adjusting the permissions as described below ("if all else fails"). Full instructions can be found here: [1]

If you are not using Ste's OpenSSH package, follow these instructions:

  1. We'll need to enable public key logins via SSH. Edit /etc/sshd_config:
nano /etc/sshd_config
  1. In your chosen editor, scroll down to the segment beginning with '#RSAAuthentication', and set it up as follows:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

Remove any hashes (#) at the beginning of these three lines.

  1. Hit Ctrl+X to exit, and save your changes.
  2. At this point you should be finished. Reboot your device.
reboot
  1. If you're confident you've given it time enough to start up, try logging back in. This time, you should be logged in without being asked for a password.
ssh root@<device ip>

If you're 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:
# ls -al ~/.ssh
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
  • If all else fails, try resetting the permissions on the iPod or iPhone's SSH files manually:
chmod 755 /var/root
chmod 700 /var/root/.ssh
chmod 644 /var/root/.ssh/authorized_keys

Retrieving and setting the Firewire GUID (FirewireGuid)

When you issue iphone-mount or ipod-touch-mount for the first time, the program silently attempts to generate this value using a USB connection. If you have never connected your device via USB before and try to mount it via WiFi for the first time, this step is missed and you end up with a database that your device refuses to read. This is (in nearly all cases) because the Firewire GUID (FirewireGuid) that the iPhone/iPod Touch specifically use to hash their database is either missing or invalid. To fix this manually:

  • Plug your iPhone/iPod device into your Ubuntu machine via USB
  • In Ubuntu, run ApplicationsAccessoriesTerminal
  • Issue iphone-mount or ipod-touch-mount (depending on your device) in the terminal
  • Path to /media/ipod/iPod_Control/Device ("cd /media/ipod/iPod_Control/Device", assuming you used /media/ipod for the mount location)
  • Run "sudo lsusb -v -d 05ac: | grep iSerial | awk '{print $3}' | cut -b1-16 | xargs printf "FirewireGuid: 0x%sn" > SysInfo" (Found here).
  • In your media application of choice, transfer a new song and/or sync your iPod. Depending on what media application you use, you might have to re-transfer all songs.
  • Reboot your device

You may also get the GUID directly from the device by executing:

 /usr/sbin/ioreg  -n IOIpodUSBDevice  -w 0 | grep DeviceConfiguration | cut -d '"' -f 44 | cut -c 1-16

If all goes well, your music should now be recognized on the device!

Alternative solution with MNPlight

  • Add the http://movenplay.gforge.inria.fr/iphone link to your Ipod Touch or Iphone installer.
  • Install MNPlight.
  • For Ipod Touch you need to set the "FirewareGuid" of device (see previous section).
  • Set the Fireware GUID in MNPlightPreferences.

Warning: Without this step MNPlight will corrupt your music database!

  • Copy your music in to /var/root/Media/MNPlight/Music folder of your Iphone/Ipod Touch and import it by MNPlightPlaylistsImport songs from directory

Troubleshooting

Programs fail to sync, stating the device is not present

A "gotcha" currently exists if you accidentally "sudo" the iphone-mount or ipod-touch-mount step. Doing so will create a template file set at your mount location (eg. /media/ipod) and subsequent mount operations will fail uncleanly. If this occurs, verify the device is indeed not mounted, clean out /media/ipod, verify the permissions are correct, and mount again as your normal user.

Music appears in the Ubuntu media player, but is not playable or does not appear on the iPhone/iPod device

The most frustrating "gotcha" is failing to have a correct FirewireGuid written onto your device. This is normally generated when the device is attached for the first time, assuming you had the device plugged in via USB at the time. If this hash is incorrect or not present, iTunes will refuse to load the database. If the music still doesn't appear on your iPhone/iPod, you might have to restart the music playing programme. Select music and hold down the main button for a few seconds. You'll be dumped back to the main screen. Please see the section above on setting the Firewire GUID.

Firmware 1.1.3

If you soft-upgraded to firmware version 1.1.3 with the Official iPhone Dev package (this does not seem to affect iPhones updated or restored firmware 1.1.3 iPhone jailbroken with ziPhone), there may be issues with getting in via SSH (Connection refused, timeout, etc). Uninstall the OpenSSH package, reinstall the BSD Subsystem package, then reinstall OpenSSH. Try logging back in as root, with the password as whatever you set it to in a previous firmware version, or the default, which is still 'alpine'. Once you have logged in, changes need to be made before you can mount everything properly with the ipod-convenience script. User-run programs now run as user "mobile" instead of root, and media has been moved from /private/var/root/Media to /private/var/mobile/Media. The ipod-convenience script expects them to be in the former, so a link needs to be made to point to the new Media folder. Issue

 
ln -s /private/var/mobile/Media /private/var/root/Media 

while logged into the iPhone or ipod touch via SSH. An alternative solution is to modify the ipod-convenience script (no need to create the link on the iphone/ipod touch):

cd /usr/share/ipod-convenience/
sudo cp mount-umount mount-umount.bak
sudo gedit mount-umount

and at line 62 modify:

#Mount our Music Directory
sshfs root@$IPADDRESS:/var/root/Media $MOUNTPOINT/ -o workaround=rename

into

#Mount our Music Directory
sshfs root@$IPADDRESS:/var/mobile/Media $MOUNTPOINT/ -o workaround=rename

No Coverart with Amarok

If you find that after syncing your iPhone with Amarok the coverart is missing it is very likely that you are using the wrong version of libgpod. Amarok depends on libgpod and the Ubuntu repositories version installs libgpod v2 instead of the needed libgpod v3. Workaround:

  • Uninstall libgpod v2. This will also uninstall Amarok
  • Open Synaptic and uncheck all the repositories but http://ppa.launchpad.net/ipod-touch/ubuntu
  • Refresh
  • Install libgpod v3 and Amarok
  • Re-check all the previously unchecked repositories
  • Start Amarok and connect to your iPhone
  • Make sure that the correct kind of iPod is selected in Amarok (under iPod -> iPod Models -> Mobile Phones)
  • Click on Refresh Graphics and on Disconnect (this might take a while)

You should have your Coverart correctly loaded on the iPhone afterwards.