Tag Archive for 'network'

Fuse and sshfs on MacOSX Leopard

I’m used to access distant machine’s file systems via ssh. My favorite environment, KDE, makes things easy thanks to the support of sftp:// URLs via a kio_slave. MacOSX is not as friendly and don’t have any built-in mechanism of that kind.

To get similar features in Leopard, we have to rely on MacFuse and sshfs. I’ll explain here how I’ve installed these components on MacOSX 10.5.

MacFUSE_Banner

First, download the latest MacFuse dmg and install it. FYI, the version I’ve got was MacFuse 2.0.3,2.

Then, download the sshfs executable for Leopard, either the gzipped version or the binary from the SVN as explained in the MacFuse wiki.

From a terminal, rename the binary:

sudo mv ./sshfs-static-leopard ./sshfs

Then allow the binary to be executed and place it in the system:

sudo chmod +x sshfs
sudo install sshfs /usr/local/bin

From now you can test sshfs mounting with the following command:

sshfs user@myserver.net:/folder/ /Network/distant-folder -p 22

I personally had a problem here: sshfs complained about a missing library. I fixed this by downloading the required file from the MacFusion project and copying it beside the sshfs binary:

sudo wget http://www.macfusionapp.org/trac/export/86/trunk/SSHFS/sshnodelay.so
sudo mv ./sshnodelay.so /usr/local/bin/
sudo chmod +x /usr/local/bin/sshnodelay.so

If this fail you can also check:

  • that the current user you’re logged with has access to the distant server with the ssh user@myserver.net command;
  • or that the local mount point exists (you can create it with mkdir -p /Network/distant-folder);
  • and finally, you can add the -o debug option to the sshfs command above to get additional clues.

Now we will automate the mounting of sshfs at every start.

At this point I recommend you to register the root user of your MacOSX system to the distant server:

sudo cat ~/.ssh/id_rsa.pub | sudo ssh -p 22 user@myserver.net "cat >> ~/.ssh/authorized_keys"

If doesn’t exists, we have to create the /etc/fstab to edit it:

sudo touch /etc/fstab
sudo vi /etc/fstab

And add the following directives:

dummy:user@myserver.net:/folder/ /Network/distant-folder sshfs allow_other,auto_cache,reconnect,port=22,follow_symlinks,volname="Distant folder" 0 0

As you can see I’ve added lots of options to accommodate my uses. You can get more informations about sshfs options through traditional help pages:

sshfs --help

MacOSX’s automount daemon will look for a script called mount_sshfs at start. Actually it doesn’t exists on your system, but sshfs command line is compatible with what automount expect. So creating a symbolic link will do the trick:

sudo ln -s /usr/local/bin/sshfs /sbin/mount_sshfs

Finally, we can tell automount to acknowledge all our modifications:

sudo automount -vc

How-to fix wireless DHCP on Mandriva 2009.0

In two words: dhcp_client sucks !

And now the long story…

Since the upgrade to Mandriva 2008.1, wifi stopped working on my laptop. I tried to install the 2008.1 on several machines. I tried to connect on different access points. I lowered security on the access point. I tried eveything. On desperation, I even tried to boot Windows to check that hardware was ok ! And the only log I had was this:

SIOCETHTOOL: Operation not supported

After all these tests, I was convinced that the problem had something to do with the distribution itself. Maybe a firmware issue or a bad combination of packages…

Then came the 2009.0 release. I though that an upgrade will cure my malediction. Indeed. Nothing new on wireless side. My wifi was still broken. Until I came across a tip on a random forum (I don’t remember which one) suggesting that dhcp_client could be the culprit.

So I replaced it by dhcpcd, and against all expectations, it worked !

And to not be annoyed by dhcp_client in the future, it’s wise to definitely remove it:

urpmi dhcp_client

Website Backup Script: bug fix release

14 months after the last release, here is a new version of my website backup script. As you can see in the changelog, this version is essentially released to fix some bugs.

Changelog:

  • Check version of Python (at least v2.4 is required)
  • Rename --debug option to --verbose
  • Add a --dry-run option for testing
  • Remove use of deprecated pexpect methods
  • Add and update some error messages

Website Backup Script: MySQL dumps and SSH supported.

Three months after the last version, here is a big update of my backup scripts for websites. The script was greatly improved and among new features, the most important is the support of backups over SSH and backups of MySQL databases.

Change log:

  • Each item of the user’s backup_list must specify the type property (FTP, FTPs, SSH, MySQLdump or MySQLdump+ssh).
  • The property previously known as site is now host.
  • File system structure changed: /ftp-mirror folders renamed to /mirror.
  • Add SSH backups.
  • The script is able to detect if a SSH connexion can be initiated without a password. This was designed for people who don’t like the idea of storing clear password in the script. Thanks to this feature, you can benefit public key authentication from OpenSSH.
  • Use of rsync whenever it’s possible for bandwidth efficiency.
  • FTP and FTPs (aka FTP over SSL) are now handled separately: this suppress the default fall-back to FTP if FTPs is not supported by the remote server. This is safer as it doesn’t let lftp make the decision for you to send your clear password on the net.
  • All ports are optionnal, no need to specify it you use default ports.
  • Add MySQL backups thanks to mysqldump.
  • Two mode of MySQL backups: through SSH or direct connection to server.
  • A particular database to backup can be specified. Else, all databases are backed up.
  • Much more detailed logs that include external command’s output.
  • Auto-detect the existence of required external tools and commands at launch.
  • Use pexpect lib to simulate user password input.
  • Run all external commands in english for consistency.
  • Check that the script is running in a posix environnement.
  • Fix bug related to directory creation.

If you were using a previous version of my backup script and want to use this updated version, take care of changes, especially the ones describes in the first 3 items of the change log above.

Quick How-To: Install NFS Server & Client

nfs.png

In this tiny how-to I’ll explain you how to setup a machine as a NFS server and an other one as a client. This example was written based on my experiences on Mandriva, but all commands should almost be the same for other distributions.

First, on the server, install nfs-utils:

urpmi nfs-utils

The nfs-utils package provide a daemon for the kernel NFS server and related tools. It is a much higher level of performance than the traditional Linux NFS server used by most users.

Then edit the /etc/exports file to add the list of the local folders you wqnt to share:

[root@localhost ~]# cat /etc/exports
/mnt/hdd *(rw,insecure,all_squash)

Then, to apply change, restart the NFS server:

/etc/init.d/nfs restart

In this example I simply wanted to share the /mnt/big-disk directory and all its sub-folders with anybody, with read and write access. I did this because the server was in a closed LAN, with only one client, that’s why no security, authentification or credentials to manage.

By the way, on the server, the only required services to activate at startup are the following:

  • nfs
  • nfslock
  • portmap

On client side, you also need to install nfs-utils, in order to benefit nfslock:

urpmi nfs-utils

The latter is absolutely not required, but if it’s a good idea to have it on the client side.

Then to auto-mount the distant shared folder, add the following line to your /etc/fstab file:

192.168.1.22:/mnt/hdd /mnt/distant-hdd nfs user,noatime,rsize=8192,wsize=8192,soft 0 0

Important parameters of the line above are:

  • 192.168.1.22 = IP adress of the NFS server,
  • /mnt/hdd = path of the shared folder on the server,
  • /mnt/distant-hdd = local folder where the shared folder will be mounted.

Then, you have to modify services on the client to change their default activation state.

Following services must be started at boot:

  • nfslock
  • netfs
  • rpcidmapd

Services that must should be inactivated at boot:

  • portmap
  • nfs
  • rpcsvcgssd