| 1 | [[FaqLpscToc]] |
| 2 | |
| 3 | == SSHFS == |
| 4 | SSHFS stands for '''S'''ecure '''SH'''ell '''F'''ile '''S'''ystem. The idea is to open a ssh connection on your computer as a file system. It will allow you to open the files stored in a mounted distant servor with the softwares installed on your own computer. |
| 5 | |
| 6 | For more details: |
| 7 | [http://en.wikipedia.org/wiki/SSHFS] |
| 8 | |
| 9 | ---- |
| 10 | |
| 11 | |
| 12 | == SSHFS on Linux == |
| 13 | '''For Debian-like distribution :''' |
| 14 | |
| 15 | '''Installation and Setup''' |
| 16 | |
| 17 | Simply install the following package:'' sshfs'', then add yourself to the fuse group: |
| 18 | |
| 19 | {{{ |
| 20 | sudo gpasswd -a $USER fuse |
| 21 | }}} |
| 22 | |
| 23 | Alternatively, GNOME users can go to System -> Administration -> Users and Groups -> (your user) -> Properties -> User Privileges, then tick the following option: |
| 24 | |
| 25 | Allow use of fuse filesystems like LTSP Thin Client blockdevices |
| 26 | |
| 27 | Adding yourself to the fuse group lets you use the fusermount command, which is needed by the FUSE userland filesystem utility. |
| 28 | |
| 29 | Once you have added yourself to the fuse group, you should log out and log back in again for the change to take effect. |
| 30 | |
| 31 | '''Command-line Usage''' |
| 32 | |
| 33 | Now, assuming that you have an SSH server running on a remote machine, simply run the SSHFS command to mount the remote directory. In this example, the remote directory is /projects on remote host far. The local mount point is ~/far_projects. |
| 34 | |
| 35 | {{{ |
| 36 | mkdir ~/far_projects |
| 37 | sshfs -o idmap=user $USER@far:/projects ~/far_projects |
| 38 | }}} |
| 39 | |
| 40 | To unmount : |
| 41 | {{{ |
| 42 | fusermount -u ~/far_projects |
| 43 | }}} |
| 44 | |
| 45 | To add it to your /etc/fstab (if you want your remote directory to be mounted when you start your computer), |
| 46 | |
| 47 | {{{ |
| 48 | sshfs#$USER@far:/projects /home/$USER/far_projects fuse defaults,idmap=user 0 0 |
| 49 | }}} |
| 50 | |
| 51 | Note that you have to change $USER to your login name when editing fstab, but it is not necessary when typing commands (the shell does it for you in that case). |
| 52 | |
| 53 | One thing to be aware of is that your UID (User ID, the unique number of your user on a system) is not necessarily the same on the two hosts. When you ls -l, the user name associated with each file is printed in the third column. However, in the filesystem, only UIDs are stored, and ls simply looks up the UID and finds the user name associated with it. In Unix, UIDs are what matter, not the user names. So if you're 1000 on the local host and 1003 on the remote host, the sshfs mounted directory would show a different user name for your files. This is not a problem, though, because the ssh server on the remote machine is what is actually reading and writing files. So even though it shows up in ls -l as a different UID, any changes will be done through the ssh server on the remote host, which will use the correct UID for the remote machine. Problems may arise if you attempt to use a program that looks at UIDs of files (e.g. ls prints the wrong user name). |
| 54 | |
| 55 | The idmap=user option ensures that files owned by the remote user are owned by the local user. If you don't use idmap=user, files in the mounted directory might appear to be owned by someone else, because your computer and the remote computer have different ideas about the numeric user ID associated with each user name. idmap=user will not translate UIDs for other users. |
| 56 | |
| 57 | '''Keep Alive''' |
| 58 | |
| 59 | Your ssh session will automatically log out if it is idle. To keep the connection active (alive) add this to ~/.ssh/config or to /etc/ssh/ssh_config on the client. |
| 60 | {{{ |
| 61 | ServerAliveInterval 5 |
| 62 | }}} |
| 63 | This will send a "keep alive" signal to the server every 5 seconds. You can usually increase this interval, and I use 120. |
| 64 | |
| 65 | == SSHFS on MACOS == |
| 66 | First of all you need to install the Apple's Xcode developer tools and the X11 windowing system (installed by default since MACOS 10.5 Leopard). |
| 67 | |
| 68 | You also need to be super user on your mac. To do so, one can do: |
| 69 | |
| 70 | {{{ |
| 71 | sudo passwd root |
| 72 | Enter Password: |
| 73 | Changing password for root |
| 74 | New password: |
| 75 | Verify password: |
| 76 | }}} |
| 77 | |
| 78 | Then go to [http://www.macports.org/install.php] |
| 79 | |
| 80 | [[Image(Macport.png)]] |
| 81 | |
| 82 | Download and install the macport version that corresponds to your MACOSX version. |
| 83 | Restart your terminal, you can now start to use macport. |
| 84 | |
| 85 | For example you can try: |
| 86 | |
| 87 | {{{ |
| 88 | port search sshfs |
| 89 | }}} |
| 90 | It should give you: |
| 91 | |
| 92 | [[Image(searchsshfs.png)]] |
| 93 | |
| 94 | The next step is to install sshfs using the following command: |
| 95 | |
| 96 | {{{ |
| 97 | sudo port install sshfs |
| 98 | }}} |
| 99 | |
| 100 | It might crash at some point asking you to install the java developer tool. You need to install this tool by registering as an apple developer (it's free but it takes some time to get registered): |
| 101 | [https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/wa/login?appIdKey=D634F5C410E183A7BD8650B11A7C825F5A871BDB2392FE747A51628F0291F620&path=%2F%2Fmembercenter%2Findex.action] |
| 102 | |
| 103 | Then you should rerun the command. |
| 104 | It should take 30 minutes to get installed on your computer. Then you need to restart. |
| 105 | |
| 106 | |
| 107 | The last step is to create a mounting point on your computer. One can do: |
| 108 | {{{ |
| 109 | mkdir /LPSC_MP/ |
| 110 | }}} |
| 111 | |
| 112 | You could know connect to the lpsc server using sshfs: |
| 113 | {{{ |
| 114 | sshfs username@lpsc-ssh.in2p3.fr:/yourfavoritedirectory /LPSC_MP/ |
| 115 | }}} |
| 116 | |
| 117 | If you open a finder and go to Macintosh HD (directory /), you could open the LPSC_MP directory and find all your files on the server. |
| 118 | [[Image(LPSC_MP.png)]] |
| 119 | |
| 120 | Enjoy ! |
| 121 | |
| 122 | To disconnect simply do: |
| 123 | {{{ |
| 124 | umount /LPSC_MP |
| 125 | }}} |