Archive

Posts Tagged ‘rsync’

Installing OpenSSL, OpenSSH, and RSYNC on Solaris 2.6 (SunOS)

November 7th, 2008

Yes, I know this is ancient stuff, but I have no choice but to mess with it right now.  Old ultrasparc garbage, weeee!  So here goes the installation of some ‘modern day’ packages so I can work with this old box.  (It hasn’t been touched since 2002, ouch)

First you’ll need to download the following packages from ftp.sunfreeware.com, gunzip them, then install them with pkgadd:

# pkgadd -d libgcc-3.4.6-sol26-sparc-local.gz

# pkgadd -d egd-0.8-sol26-sparc-local.gz

# pkgadd -d popt-1.7-sol26-sparc-local.gz

# pkgadd -d zlib-1.2.3-sol26-sparc-local.gz

# pkgadd -d prngd-0.9.25-sol26-sparc-local.gz

# pkgadd -d openssl-0.9.8i-sol26-sparc-local.gz

# pkgadd -d openssh-5.1p1-sol26-sparc-local.gz

# pkgadd -d rsync-3.0.4-sol26-sparc-local.gz

Create some new directories:

/var/spool/prngd/

/var/run/

Create a startup script for the random number generator in /etc/init.d

#!/bin/sh
# 10/04/2008
# Purpose: start, stop, status script for prngd
case “$1″ in
’start’)
/usr/local/sbin/prngd /var/spool/prngd/pool /var/run/egd-pool
;;
’stop’)
/usr/bin/kill `ps -ef | /usr/bin/grep prngd | /usr/bin/grep local | /usr/bin/awk ‘{print $2}’`
;;
’status’)
if [ "`ps -ef | /usr/bin/grep prngd | /usr/bin/grep local`" ]; then
echo prngd is running…
else
echo prngd is stopped.
fi
;;
*)
echo “Usage: $0 { start | stop | status }”
exit 1
;;
esac
exit 0

Create a startup script for sshd in /etc/init.d

#! /bin/sh
#
# start/stop the secure shell daemon
case “$1″ in
’start’)
# Start the ssh daemon
if [ -f /usr/local/sbin/sshd ]; then
echo “starting SSHD daemon”
/usr/local/sbin/sshd &
fi
;;
’stop’)
# Stop the ssh deamon
PID=`/usr/bin/ps -e -u 0 | /usr/bin/fgrep sshd | /usr/bin/awk ‘{print $1}’`
if [ ! -z "$PID" ] ; then
/usr/bin/kill ${PID} >/dev/null 2>&1
fi
;;
*)
echo “usage: /etc/init.d/sshd {start|stop}”
;;
esac

Don’t forget to link them both in /etc/rc2.d so they’ll start automatically.  I used 50 and 99 to try to make sure that prngd starts before sshd fires up.

# cd /etc/rc2.d

# ln -s ../init.d/prngd S50prngd

# ln -s ../init.d/sshd S99sshd

Create ssh public key pairs.  Don’t change these output names, the daemon expects them to be named like this and if you change them, you’ll see an error like no key found, ssh v1 not starting.  But who really cares, right?

# /usr/local/bin/ssh-keygen -d -f /usr/local/etc/ssh_host_dsa_key -N “”

# /usr/local/bin/ssh-keygen -b 1024 -f /usr/local/etc/ssh_host_rsa_key -t rsa -N “”

# /usr/local/bin/ssh-keygen -t rsa1 -f /usr/local/etc/ssh_host_key -N “”

Start the daemons and you should be good to go.  If you’re getting PRNGD not seeded errors, go take care of some other stuff, it will eventually stop as long as you installed prngd properly and started it up.  Generating the keys will probably take forever if you’re on an old Ultra 1 like me, give them a minute or two.  Entropy will take forever+1.  You can fill the seed files with garbage data if you want to speed it up.  If you’re still getting PRNGD errors an hour later, you could try the kernel patch to add /dev/random /dev/urandom support directly to the kernel.  (Sun patch 112438-03) I chose not to because I didn’t want to risk something going terribly wrong with this machine.  It’s unique in my environment and been shoved in a corner and forgotten about for a long time until now!

I also installed bash and top.  Bash was a no brainer!  I hate old ksh shells with broken backspaces, arrow keys, and lack of a command history.  They were both installed with pkgadd -d, no additional script writing or directory creating necessary.  If you have library issues after installed, run ldd on the binaries and do a google search to find what libraries packages you need.

Uncategorized , , , , , , , , , , , , , ,

Setup your own YUM repository, the easy way!

September 25th, 2008

I don’t understand why some people think this is a complicated thing to set up, so here goes my approach which I think is the easiest method.  Perhaps you’re behind a very restrictive corporate firewall or you want to conserve bandwidth when you’re setting up several machines.  You can set up your own repositories on one machine in your network and have it download the packages and updates in the off-hours.  Whenever a client machine on your network wants updates, they’ll get them much faster and you’ll save bandwidth too.

Step-by-step:

Install createrepo on the machine you want to be your update server.

[user@hostname ~]$ sudo yum install createrepo

Now you’ll create a few crons to create and maintain your mirror.  Let’s start with the one that does the grunt work of downloading the packages.  I’ll go ahead and set a bandwidth limit and log my mirroring.  I don’t care about debug stuff so i’ll exclude that and any iso’s that may get dumped in there too.

#!/bin/sh
# GET THE LATEST PACKAGES
/usr/bin/rsync -aq –bwlimit=500 –stats –log-file=/var/log/rsync/i386.rsync.1.log rsync://your-favorite-linux-mirror/linux/updates/9/i386.newkey/ –exclude=debug/ –exclude=*.iso /opt/yum/updates/8/i386/
/usr/bin/rsync -aq –bwlimit=500 –stats –log-file=/var/log/rsync/x86_64.rsync.1.log rsync://your-favorite-linux-mirror/linux/updates/9/x86_64.newkey/ –exclude=debug/ –exclude=*.iso /opt/yum/updates/8/x86_64/

Create a cron to update your repo as new rpms get mirrored.

#!/bin/sh
# CREATE/MAINTAIN MY LOCAL REPOSITORY
/usr/bin/createrepo –update /opt/yum/base/8/i386
/usr/bin/createrepo –update /opt/yum/base/8/x86_64

Create another cron to rotate your logs, saving the last week’s worth.

#!/bin/sh
# ROTATE THE LOGS
rm -f /var/log/rsync/yum-rsync-log7.tar.gz
mv -f /var/log/rsync/yum-rsync-log6.tar.gz /var/log/rsync/yum-rsync-log7.tar.gz
mv -f /var/log/rsync/yum-rsync-log5.tar.gz /var/log/rsync/yum-rsync-log6.tar.gz
mv -f /var/log/rsync/yum-rsync-log4.tar.gz /var/log/rsync/yum-rsync-log5.tar.gz
mv -f /var/log/rsync/yum-rsync-log3.tar.gz /var/log/rsync/yum-rsync-log4.tar.gz
mv -f /var/log/rsync/yum-rsync-log2.tar.gz /var/log/rsync/yum-rsync-log3.tar.gz
mv -f /var/log/rsync/yum-rsync-log1.tar.gz /var/log/rsync/yum-rsync-log2.tar.gz
mv -f /var/log/rsync/yum-rsync-log.tar.gz /var/log/rsync/yum-rsync-log1.tar.gz
tar -czf /tmp/yum-rsync-log.tar.gz /var/log/rsync/*.log
rm -rf /var/log/rsync/*.log
mv -f /tmp/yum-rsync-log.tar.gz /var/log/rsync/

On your client machines, move or delete the existing repo definitions and create a new one that points to your local repositories.  Assuming your server machine’s IP address is 192.168.1.2 and you’re using Fedora your new repo definitions would look something like this:

[fairfield-base]
name=My_Local_Repo - base - Fedora $releasever - $basearch
failovermethod=priority
baseurl=http://192.168.1.2/yum/base/$releasever/$basearch
enabled=1
gpgcheck=1

[fairfield-updates]
name=My_Local_Repo - updates - Fedora $releasever - $basearch
failovermethod=priority
baseurl=http://192.168.1.2/yum/updates/$releasever/$basearch
enabled=1
gpgcheck=1

Wait until your cron fills your repositories or download a few packages and run your createrepo.  From now on your updates will execute much faster.  And if you want to build new machines, you can point your kickstart to get packages from your local mirror instead of just your cdrom so you can build machines that are fully up to date right out of the box.  Try updating on your clients.  You should notice it takes ten times longer to install the updates than it does to download them.

[user@hostname ~]$ sudo yum update

root|ninja

Linux , , , , , , ,