Sometimes I need to access a drive on a remote computer and pluck out a file I need. I don’t need to do it often, I don’t want or need a VPN or any other kind of thing. I just want to mount the drive over SSH and pluck that file.
Here is how I do it on the Nokia N900
There is a bit of typing involved and whilst the N900 keyboard is good It’s easer to SSH in and do it from the laptop. So install ssh server on the N900
I installed ssh server from the Application Manager. It asks you to set a root pass on install. We are going to need the ssh client as well, I have previously installed this but if you haven’t choose the ssh client and server app instead.
You probably want to set up keys for access but can stick with password if security or your memory is not a worry. There is a good guide on talk.maemo.org on how to do this.
Open XTerminal and find the IP address of the N900 using ifconfig (I’m connecting via my wireless network)
Open a terminal on your laptop or desktop and SSH in to the N900
Add the extras development repositories
Echo "deb Http://Repository.maemo/Org/Extras-Devel/ Fremantle Free Non-Free" "/ etc / apt / sources.list.d / extras-Devel.list Apt-get update
Then install sshfs
sudo apt-get install sshfs
Before I create a mount point I should mention that initially I could not see the full file structure of /home/user/MyDocs in XTerminal - I could see /home/user/MyDocs/DCIM but nothing else even though I could see more directories in the gui file manager. I installed GPE file manager from the Application manager and this fixed this in XTerminal. I presume it must has installed some extra dependencies. Though not sure what.
Create a mount point on the N900
Next you create an SSH tunnel
ssh -L localhost:22:192.168.254.21:22 126.96.36.199 -p 22
Then mount using sshfs
sshfs username@localhost:/ /home/damien/mounts/wkstn00 -p 22
(You don’t need those 22’s in there or the -p switch as it’s the default port for SSH but for security you should change ssh to run off a different port and put that port number in there instead)
If this works make it into a script and put in /usr/bin so it can be run as a command. To do this modify the ssh tunnel command by forking it -f and putting a delay to let it connect before running the sshfs mount command.
ssh -f -L localhost:1233:192.168.254.21:22 188.8.131.52 -p 1234 sleep 10
Below is my full script. In the script I have replaced my internal IP addresses with 184.108.40.206 and external with 220.127.116.11, my non standard ports I have also changed to 1234 and 1233. I added a routine to check for a number of switches - the example below will mount over ssh, create a vnc session over ssh (you’ll have to install vnc) or run a file you feed to it.
#! /bin/bash #thanks to http://tldp.org/LDP/abs/html/testbranch.html for the command line parameter testing routine while [ $# -gt 0 ]; do # Until you run out of parameters . . . case "$1" in -myWorkstation|-w) # myWorkstation parameter? # tunnel to myWorkstation ssh -f -L localhost:1233:18.104.22.168:22 22.214.171.124 -p 1234 sleep 10 #mount filesystem sshfs damien@localhost:/ /home/username -p 1233 ;; -vnc|-v) #vnc parameter? #tunnel to myWorkstation ssh -f -L localhost:1234:126.96.36.199:5900 188.8.131.52 -p 1234 sleep 10 #vnc to machine vncviewer localhost:1234 ;; -c|--conf) CONFFILE="$2" shift if [ ! -f $CONFFILE ]; then echo "Error: Supplied file doesn't exist!" exit $E_CONFFILE # File not found error. fi ;; esac shift # Check next set of parameters. done
Save this script to /usr/bin with a cool name and appropriate execute permissions
chmod +x /usr/bin/mymount
Then run the script with the switch
I then discover it won’t mount as the N900 user is not part of the group that owns fuse. I look at /dev/fuse and see it is owned by root and has group root - ie
ls -l /dev/fuse
gives permissions as root:root. This maybe because I am ssh-ing in as root from the laoptop, and installed sshfs that way. This is never recommended, I will create a proper non root ssh user in future.
To fix this a sensible person might set up new group called fuse and set to root:fuse then add user to fuse group.
So at his point I added adduser
sudo apt-get install adduser
However I am again lazy and just set /dev/root to be owned by user. Only for the time being you understand.
chown user:root /dev/fuse
The mount command mymount -w now runs fine as user and after running it I can browse the remote drive via the standard GUI file manager on the N900 as if it’s a local drive.
blog comments powered by Disqus