Creating credential files for automatic Samba mounts in /etc/fstab

November 27, 2009

It’s handy to have credentials for each Samba server so you don’t have public passwords in /etc/fstab for the Samba file systems you want to mount on boot. Here’s how I do it:

  1. Create a directory /etc/samba/credentials
  2. Create a file /etc/samba/credentials/myserver
  3. In the myserver file, put the credentials for that server:
    username=myusername
    password=mypassword
    

    Note: spaces are important here – don’t use “ = ”, use “=”.

  4. chown -R root.root /etc/samba/credentials
  5. chmod 700 /etc/samba/credentials
  6. chmod 600 /etc/samba/credentials/myserver

Once this is done, you can add lines for each mount of that server to your /etc/fstab:

//myserver/music        /music  smbfs   credentials=/etc/samba/credentials/myserver 0 0
//myserver/shared       /shared smbfs   credentials=/etc/samba/credentials/myserver 0 0

Note that the file in /etc/samba/credentials doesn’t have to be named the same thing as the server name – it just makes it easier.

This also survives the Ubuntu upgrade process, so you just have to update /etc/fstab if you upgrade to a new release, and can keep the same credentials files.


Setting up Samba on Ubuntu Server 8.04

November 26, 2009

It’s been a few years since I last set up a Samba system, and the process is still as painful as ever. A lot of this pain comes from multiple authentication systems, which all have to be in sync for things to work.

I started out with the link here:
http://ubuntuforums.org/showthread.php?t=202605
and pretty much ignored all of it. In the end, I took the default 8.04.3 /etc/samba/smb.conf, and made the following changes:

  • Set the workgroup in the global stanza
  • Added stanzas like the following:
    [music]
        path = /music
        browseable = yes
        read only = no
        guest ok = no
        create mask = 0644
        directory mask = 0755
        force user = andrew
        force group = sambashare
    

Note that I’m using user permissions, not share permissions. So I had to add and enable the Samba user:

sudo smbpasswd -L -a andrew
sudo smbpasswd -L -e andrew

Originally, I had force group = andrew. When I tried to mount using this option, I’d see:

$ sudo mount -a
mount error(5): Input/output error
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

What lovely error messages. I found a semi-useful diagnostic tool, smbclient:

smbclient //server/music -U andrew
Enter andrew's password: 
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28a]
tree connect failed: NT_STATUS_NO_SUCH_GROUP

I did have an andrew group, but the user andrew wasn’t in that group according to /etc/group, so I switched to sambashare (which does have andrew as a member). Then it worked. Just adding andrew as a member of the group andrew in /etc/group was not sufficient. No idea why, but probably Samba has some concept of groups that needs to be set up too.

Next, I tried to connect again:

smbclient //server/music -U andrew
Enter andrew's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28a]
tree connect failed: NT_STATUS_BAD_NETWORK_NAME 

This let me search on NT_STATUS_BAD_NETWORK_NAME and discover that, gee, that means permissons are bad for the directory that is being shared. Nothing better than helpful error messages.

A final /etc/init.d/samba restart and I could connect.


Compiling soundmodem-0.14 on Ubuntu 9.10

November 21, 2009

The soundmodem that ships with Ubuntu 9.10 is not the latest. The latest is available here:

http://www.baycom.org/~tom/ham/soundmodem/

In order to compile it, you need to install a bunch of development packages. Here’s what I did:

sudo aptitude install libasound2-dev
sudo aptitude install libxml2-dev
sudo aptitude install libgtk2.0-dev 
sudo aptitude install libaudiofile-dev

Also, if you don’t have the compiler already you’ll need:

sudo aptitude install g++

Then:

tar xzvf soundmodem-0.14.tar.gz
cd soundmodem-0.14
sh ./configure
make

To test it, go to the configapp/src directory and run

sudo ./soundmodemconfig

to set up the configuration. Finally, go to the soundcard directory and run:

sudo ./soundmodem -v5

Assuming you’ve configured everything correctly, you should see something like:

sm[10093]: mkiss: ifname sm0 mtu 256 hwaddr CALLSIGN-0 ipaddr 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255
sm[10093]: unknown node "text"
ALSA: Using sample rate 9600, sample format 2, significant bits 16, buffer size 4800, period size 150
ALSA: Using sample rate 9600, sample format 2, significant bits 16, buffer size 4800, period size 150
sm[10093]: audio: starting "plughw:0,0"

In a different terminal, you can then ifconfig sm0 to see that it’s there.