How to run samba on your iphone

This doc is a step buy step on howto install and configure samba on you iphone.  Following these step will allow you to connect to iphone from windows or mac as a network share. This connection direct to iphone via adhoc network. But if you want to route it behind a firewall will work fine as well

Assumptions
I assume your iphone is freed and able to install 3rd party apps and  you already have sshd enabled if you do not  you will need to complete that step before continuing.

Install Details
I have simplified the config files and removed many advanced setting so be warned default value are in place. If you want to further secure the share you will need to add to the config in. The install files were striped of binary that are not needed to try to save space if you want full/advanced functionallity please download the full tar ball from http://wickedpsyched.com/iphone/samba/ . (Thanks x for provide the original binaries) Logging is also set to minimal and redirected away from root, this was done so that root file system will not fill up with logs and crash your phone. If you want to get debug message you will need to modify the logging level. I do not go into the security concerns of running smb (I assume you know what you are doing when you enable network file sharing).

Lets get started

0. Prerequisite
Download iPhone samba files
http://signalblue.com/iphone/iphone_samba-v1.tar
(stripped down)

This tarbal contains minimal smb.conf, iphone specific startup scripts and default user passwd file.
Download winscp (only needed if you are running windows. If you are using Linux or any other unix base os install openssh then use ssh)
http://signalblue.com/iphone/tools/winscp.exe

Download putty (only needed if you are running windows. If you are using Linux or any other unix base os install openssh then use scp)
http://signalblue.com/iphone/tools/putty.exe

(if you are on mac use a shell, rbrowser or you any other ssh/scp client )

Step1. Prepare iphone
   
    Disable Auto-Lock feature (auto lock will terminate you ssh and smb connections) Note make sure to re-enable it when you are not using the network features.

    I like to create a peer-to-peer network that way I can connect my phone wirelessly to my laptop when I am at the airport.
    (if you are using a access-point and have a natted ip you can just use it)
    Now create a peer-to-peer you mac or pc
    I have pc screen shots because I don't have a mac. Hopefully that will soon be rectified son :-)

Go to iphone. and turn off WiFi
    From the menu Settings>General>Network>WiFi>Then select off
    



Disable Wep and enter iphone-net as SSID and set as ad-hoc



Set ip address as 192.168.1.201

    Settings>General>Network>WiFi> Then select enable Wifi
    You should see a SSID iphone-net
    Select it and configure ip as static
    The smb config file is already setup for 192.168.1.200
    So if you want to make it easy on yourself just
    set your ipaddress to 192.168.1.200
    set your netmask to 255.255.255.0
    go back to WiFi - Networks
    and check iphone-net
    You should now be connect to iphone on a peer-to-peer wifi link
    Open a cmd shell and ping iphone

  

Step 2: Upload samba tarball
Login in to iphone
username:root
password dottie


Copy iphone_samba.tar to root
file:///C:/Documents%20and%20Settings/D001618/Desktop/iphone/howtos/img/copy_tarball.bmp

Step 3: Login via putty and run the following command

Note: All command should be ran with out # sign (But I am sure you new that)

#mv iphone_samba-v1.tar /usr/local

#cd /usr/local
#ls -l
-rw-r--r-- 1 root wheel 9195520 Oct 15 02:43 iphone_samba-v1.tar

# tar -xvf iphone_samba-v1.tar
samba/
samba/lib/
samba/lib/smb.conf
samba/libsmbsharemodes.a
samba/nmbd
samba/private/
samba/private/secrets.tdb
samba/private/smbpasswd
samba/smbd
samba/smbpasswd
samba/smbstatus


#touch /etc/printcap
#mkdir -p /var/root/apps/log/var
#mkdir -p /var/root/Media/ROMs
#mkdir -p /var/root/Media/PDF
#mkdir -p /var/root/Media/Files


# cd samba
# ls -l
total 8960
drwxr-xr-x 2 root wheel     102 Oct 15 02:42 lib
-rw-r--r-- 1 root wheel    6200 Oct 15 00:14 libsmbsharemodes.a
-rwxr-xr-x 1 root wheel 1519224 Oct 15 00:14 nmbd
drwxr-xr-x 2 root wheel     136 Oct 15 02:18 private
-rwxr-xr-x 1 root wheel 4166552 Oct 15 00:14 smbd
-rwxr-xr-x 1 root wheel 2354852 Oct 15 00:14 smbpasswd
-rwxr-xr-x 1 root wheel 1121748 Oct 15 00:14 smbstatus

#ln -s /var/root/apps/log/var (This will make sure that you do not fill up your root fs with logs)
Note: I recommed deleting the logs every once in a while to conserve space.

the first  time you start samba the following files will be created
drwx------ 4 root wheel  136 Oct 15 03:20 cores
drwxr-xr-x 4 root wheel  748 Oct 15 03:27 locks
-rw-r--r-- 1 root wheel  982 Oct 15 03:27 log.nmbd
-rw-r--r-- 1 root wheel 2185 Oct 15 03:27 log.smbd

Step 4: Start Samba on iphone
You can do this from the iphone if you have mobile terminal installed
If not log in via putty and start it
command

#/usr/loca/samba/smb.sh start
To stop service just use /usr/local/samba/smb.sh stop

Step 5: Connect to iphone (and mount share)
On windows Start >Run > \\192.168.1.200
On mac use network connect
On linux use smbclient

Step 6: Login
Default user in the passwd file is root password is iphone
Note you can use smbpasswd to create other uses (You will need to how to map uid and gid to file perms to map)
If you dont know what that mean I would worry about it use root/iphone (a change of passwd is recommend)
you can do that via the command #smbpassd root from the ssh session.


If all goes well your iphone shares should be displayed



Enjoy

Last reminder: I would disable smb when not used (I would be nice to create a native app that can disable and enable services)
Also
Renable auto lockout when you don't use network services. (Alway secure you phone)