howto

Scripted setting of users passwords; RHEL/CentOS and now Ubuntu/Debian/others too

0

I’ve been set­ting users pass­words suc­cess­fully on CentOS/RHEL from within my kick­starts, using entries like this:

echo p4ssw0rd | passwd --stdin username

… how­ever, that unfor­tu­nately doesn’t work on at least Ubuntu (and pos­si­bly many other dis­tros as well).

Now — finally — and thanks to this com­ment, I have an answer; and it looks some­thing like this:

echo username:password | chpasswd

start-stop-daemon on CentOS/RHEL

0

(Note that I’ve only ever done this on Cen­tOS 6.2. It should work in a lot of other places too though, espe­cially other RHEL based distros.)

I really wanted to use the Smokeping init script that comes with Ubuntu 10.04.* LTS  on a Cen­tOS 6.2 box. One look at it, how­ever, and you will very quickly realise that out-the-box that isn’t some­thing which is likely to work, pos­si­bly for other rea­sons, but def­i­nitely because you don’t have “start-stop-daemon” on a Cen­tOS box; not yet at least :)

This help­ful post sug­gested that if you pull the dpkg source from one of the Debian mir­rors then you could build it, albeit quite nas­tily, and end up with a suc­cess­ful build of start-stop-daemon. How­ever, it doesn’t have to build so nas­tily. Newer ver­sions of dpkg build cleanly, as I dis­cov­ered and have detailed below. As root or using sudo, do the following:

cd /usr/local/src
wget -c "http://za.archive.ubuntu.com/ubuntu/pool/main/d/dpkg/dpkg_1.15.8.4ubuntu3.tar.bz2"
tar jfxvh dpkg_1.15.8.4ubuntu3.tar.bz2
rm dpkg_1.15.8.4ubuntu3.tar.bz2
cd dpkg-1.15.8.4ubuntu2/
./configure --without-install-info --without-update-alternatives --without-dselect
make && make install

Now if you type “which start-stop-daemon” you should dis­cover that it’s built and installed into /usr/local/sbin, and works per­fectly just like it’s sup­posed to. And with that hur­dle out the way, I could now fin­ish get­ting that Ubuntu init script work­ing on Cen­tOS. Happy time :)

The easiest way to fix apt missing key issues

0

Sorry, this is a bit lazy of me, but at the moment I can only con­firm that this works on Ubuntu 10.04.4 LTS. It might, how­ever, work on other ver­sions too, and maybe also with Debian of course.

If when you run an apt-get update you are being told some­thing like this right at the end:

W: GPG error: http://196.x.y.z lucid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 2940ABA983EF826A

… then install “add-apt-key” on the box, and run it, adding the miss­ing key itself to the end of the com­mand, as shown below.

root@xyz-box-bry-01:~# apt-get install add-apt-key
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  add-apt-key
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 5,314B of archives.
After this operation, 81.9kB of additional disk space will be used.
Get:1 http://196.x.y.z/ubuntu/ lucid/universe add-apt-key 1.0-0.5 [5,314B]
Fetched 5,314B in 0s (270kB/s)
Selecting previously deselected package add-apt-key.
(Reading database ... 88896 files and directories currently installed.)
Unpacking add-apt-key (from .../add-apt-key_1.0-0.5_all.deb) ...
Processing triggers for man-db ...
Setting up add-apt-key (1.0-0.5) ...
root@xyz-box-bry-01:~# add-apt-key 2940ABA983EF826A
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: requesting key 83EF826A from hkp server subkeys.pgp.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 83EF826A: public key "Opscode Packages " imported
gpg: Total number processed: 1
gpg:               imported: 1
OK
root@xyz-box-bry-01:~#

I’ve found that some­times the key server doesn’t have the key and so it’s not imported, but re-running the com­mand gen­er­ally fixes that as the next key server cho­sen usu­ally does end up hav­ing the key. Once you’ve suc­cess­fully imported the key, run “apt-get update” again and your prob­lem should no longer exist.

There was some­thing else I wanted to say but I’ve totally for­got­ten what it was.

Enjoy :)

Fixing tftpd-hpa on Lucid

1

Whilst work­ing at IS, I’ve sent VMware servers to Accra, Nairobi, Lagos, Maputo, Lon­don, Dur­ban, Cape Town and then of course to two sites in Johan­nes­burg. The servers in Accra, Nairobi, Lagos and Maputo run var­i­ous vir­tual machines required by the NMS team (of which I am a mem­ber), as well as a whole lot that a sis­ter team of ours uses. The NMS machines are things like Sys­log boxes and SNMP gate­ways, etc.

Con­nec­tiv­ity to those regions is any­where from awe­some — if that region is on the east­ern side of Africa and con­nects via Sea­com — right down to pretty much unus­able. The kind of unus­able where you spend a whole day just try­ing to log into the con­sole of a vir­tual machine because every time you try to write “root” the word will come out as “rroot” and then “rooooot” and then “rootttt”. It’s one of the most frus­trat­ing things I’ve ever had to do in my life, I’m sure of it.

Which kinda brings me to the point of this post. I decided that the best way to deploy the var­i­ous machines (given that there’s never any time to send the VMware server itself to the region with all the vir­tual machines already built) was to kick­start them, using pre­seeds for the Ubuntu boxes and kick­starts for the CentOS/RHEL boxes. This has worked famously for me, and I’m now able to have fully built, NMS stan­dards com­pli­ant vir­tual machines in any of those regions in ten min­utes or less.

That was until I upgraded the key infra­struc­ture boxes (dhcp & tftp servers etc.) to Lucid. Sud­denly every­thing ground to a halt. The fix how­ever was very sim­ple. In fact I feel kinda guilty that you’ve had to read this whole long story just to get such a sim­ple solu­tion to your problem.

Before Lucid these boxes ran Hardy. I used tftpd-hpa run­ning as a dae­mon, using the stan­dard /var/lib/tftpboot direc­tory as the TFTP root. My /etc/default/tftpd-hpa file looked like this:

#Defaults for tftpd-hpa
RUN_DAEMON="yes"
OPTIONS="-l -s /var/lib/tftpboot"

After upgrad­ing to Lucid that file had changed so that it looked like this:

# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS=""

How­ever the ser­vice wouldn’t start and the net­work installs kept on fail­ing to even start. Chang­ing the con­tents of /etc/default/tftpd-hpa to look more like this solved my prob­lem. The “4” is because I switch IPv6 off on all my Lucid machines by adding “ipv6.disable=1″ to the “GRUB_CMDLINE_LINUX_DEFAULT” line in /etc/default/grub.

# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-4 --secure"

Bounce the ser­vice and you’re sorted, and back on the road with your net­work installs. :)

Go to Top