Configuring Syslog-NG using SSH on Solaris

Objective

The objective of this exercise is to enable remote systems (clients) to be able to write to the System Log on a central Log Server (server), without losing the ability to write to their own local system log. This is achieved by creating a reverse SSH tunnel from the server to each client (on a special port) such that if the client configures their system log to use that port, the log entry will be sent across the tunnel to the log server.

Configuring SSH Access between Client and Server

The server will need to create an SSH connection to each client. The SSH tunnel will be initiated by the root user at the server but SSH connections by root have been disabled on all of my clients (for obvious reasons) so we will need to use a non-root user to create the SSH tunnel (e.g. someuser). The steps below were used to set up SSH access between server and client:

  1. Create a public key on the server as the user who will initiate the SSH tunnel to the clients (root)

    server# ssh-keygen –t rsa

  2. Copy the resultant public key file to the SSH directory for the someuser at the client

    server# scp /.ssh/id_rsa.pub someuser@remotehost:

  3. At the client, append the public key file just copied to the ~someuser/.ssh/uthorized_keys file

The server should now be able to crate an unchallenged SSH connection to the client (as user someuser)

Configuring SSH Tunnelling

Syslog normally uses port 514 and it follows that this is the port that would need to be tunnelled from the clients to the server in order to enable remote logging. However, the non-root user at the client (someuser) will not be allowed to open port 514 since it is below the range of ports it has access to (only root can access ports below 1024 on Unix). Therefore, what we require is a tunnelled connection from a port above 1024, say 1514. If you are using a firewall or IP Packet Filtering software, you will also need to configure this to allow TCP traffic on port 514 at the server.

Use the following command to test the reverse SSH tunnel between the server and client:

server# /usr/bin/ssh -nNTx -R 1514:127.0.0.1:514 someuser@remotehost.domain.com

If this works, then proceed to the next step. If it does not, try adding –vv to the ssh command to see additional information about why. I had a problem here and it turned out that port forwarding was disabled at my client. To enable port forwarding, I modified the SSH configuration after which I restarted SSH at the client:

client# vi /etc/ssh/sshd_config
Change the value of AllowTcpForwarding to yes
client# svcadm refresh ssh

Automating SSH Tunnelling

To enable the server to automatically create a reverse tunnel to a given client, the following entry should be added to the /etc/inittab file at the server:

log1:3:respawn:/usr/bin/ssh –nNTx
-R 1514:127.0.0.1:514
someuser@remotehost.domain.com > /dev/null 2>&1

This should occupy a single line only (but has been split over several lines here to increase readability). This someuser and remotehost.domain.com should be replaced with a valid user and client hostname for your system.

Configuring the Log Server

  1. Download the syslog-ng package from campin.net and copy it to the system that will become the loghost (do not install it yet). You could obtain a copy of syslog-ng from sunfreeware.com but the one from campin.net installs as a proper SMF service on Solaris and is a cleaner package to work with.
  2. Now remove the existing system-log service from the server. This is required so that syslog-ng can become the primary system logging service on this system.

    # svcadm disable system-log
    # svccfg delete system-log

  3. Install the syslog-ng package downloaded above:

    # pkgadd –d NCsysng-1.6.7-1.pkg

  4. Ensure that it is listed as a valid service

    # svcs –a | grep system-log-ng

  5. Edit the configuration file /usr/local/etc/syslog-ng/syslog-ng.conf (you might like to take a copy of the existing file first) and edit as appropriate:

    options {
    check_hostname(yes);
    keep_hostname(yes);
    chain_hostnames(no);
    };
    source inputs {
    internal();
    sun-streams("/dev/log");
    udp(ip("127.0.0.1"));
    tcp(ip("127.0.0.1") max_connections(100) keep-alive(yes));
    };
    destination logfile {
    file("/var/adm/syslog-ng/$HOST/$YEAR/$MONTH/$FACILITY.$YEAR$MONTH$DAY"
    owner(root) group(root) perm(0600)
    create_dirs(yes) dir_perm(0700));
    };
    log {
    source(inputs);
    destination(logfile);
    };

  6. Start the new syslog-ng service

    # svcadm restart system-log-ng

  7. Verify that the service is operating correctly (should not be listed in output from command below)

    # svcs -xv system-log-ng

Configuring the Log Client

Repeat steps 1-7 above but in Step 5, add the following 2 additional settings to the configuration file:

destination remote {
tcp("127.0.0.1" port(1514));
};
log {
source(inputs);
destination(remote);
};

Note the inclusion of 127.0.0.1 and port(1514) here. This tells the syslog service to write to port 1514 on the local system. This port represents one end of the SSH tunnel and writing to it will result is the log entry being sent to port 514 on the log server, which will result in a new entry on that log server.

Notes

  1. Some sites recommend using the keep-alive(yes) setting with the tcp() function above on the server and the client (to avoid SSH hang-ups). However, I found that this is not supported at the client and it caused my system-log-ng service to enter maintenance mode at the client. The reason given by svcs –xv was “restarting too quickly” which was very vague. I ended up searching through the manifest files for the system-log-ng service to see what command-line it was actually executing (/usr/local/sbin/syslog-ng) and then running that by hand. It was only then that I saw an error indicating an invalid parameter in my configuration file.
  2. The use of ip("127.0.0.1") in tcp() and udp() in the server configuration ensures that the log server will only listen for local traffic on port 514 on that system. This is more secure.

Useful Links

Best of luck!

The World’s Biggest Storage Networks

Byte and Switch are compiling a list of the worlds biggest Storage Area Networks (SAN) and have release some of their initial findings. The purpose of the study to assess some of the lessons learned by corporations when scaling to such gargantuan levels of storage.

The results so far are utterly astonishing and the article is well worth reading. Impressive enough is the fact that the top five each have active storage capacities in the order of Petabytes (PB) but also that the San Diego Supercomputer Centre has over 18PB of tape storage (yes, that’s right, tape) and the Department of Defense has over 20,000 Fibre Channel switch ports.

Here is a summary of the top 5 (so far) showing the key suppliers in each case.

Corporation Suppliers Disk Tape
JP Morgan Chase IBM, Sun 14PB
U.S. Department of Defense Brocade, Others
NASA SGI, Sun 1PB 10PB
San Diego Supercomputer Centre Sun 1PB 18PB
Livermore Labs SGI 2PB

Particularly interesting (but not entirely surprising) is the high use of Sun and/or SGI equipment by four of the above.

Source: SlashDot

Kids Say Email is Dead

Yet more evidence of the shift away from traditional email toward social networking. Admittedly, the trend is stronger in younger people but it is interesting nonetheless. What’s also interesting (but not surprising in the slightest) is the fact that it’s the mobile phone that is becoming the physical means of communication.

I especially like the quote that they now only use email to communicate with “adults” – that says it all for me.

Source: SlashDot

Enabling the WiFi adapter on a Fujitsu Siemens Amilo laptop

Whilst helping a friend to set up a home wireless network yesterday, I encountered a very unusual issue with the configuration of the wireless adapter on their laptop. The laptop was a Fujitsu Siemens Amilo L7320 and it was running Windows XP Home and contained an Atheros AR5005G WiFi adapter.

No matter what I tried, Windows simply refused to find any wireless networks. It kept saying that either the adapter is disconnected or the switch is off. The adapter was showing up fine in the Device Manager and there was no sign of a switch on the exterior of the laptop.

In the end, it turns out that you have to press Fn + F2 to enable the WiFi adapter on this model. Apparently, you also have to do this after each reboot, which Fujitsu Siemens claim to be a feature.

You learn something new every day!

New Free Music Download Service – We7

I heard a short article on The Last Word yesterday (on Irish Radio Station Today FM) about a new music download service that claims to provide you with free music that is completely safe and legal. The service is called We7 and is being backed by Peter Gabriel.

The way it works is that when you listen to the downloaded music you also have to listen to a short advert. However, after a certain amount of time (4 weeks I think), the advert disappears and you then own the music. The music is in MP3 format and is DRM free so should play on most music players without issue. The artist gets paid by the advertiser and this is how the music is paid for. Initially, they are planning to release with audio files only but later plan to release video and other content.

Overall, quite an interesting service but not a great name as I don’t like numbers in a company name (it took me a couple of attempts to get the domain name correct).

Click here to download a Podcast of the radio piece from The Last Word. It starts at precisely 35 minutes into the show.

Who remembers the Sinclar ZX Spectrum

Who would believe it but the Sinclair ZX Spectrum computer was launched 25 years ago today. I never owned one myself but remember being extremely envious of many others who did. God only know why since it took so long to type in even the most basic games (pardon the pun) since the model with the tape/data recorder didn’t arrive until several years later.

Anyway, go on, show your age and tell us about your ZX Spectrum.

Source: Slashdot

TWUIK from Tricast Media

TWUIK is the name of a UI technology developed by Tricast Media that claims to bring flash-like graphics, animations and advanced user interactivity to mobile application development. They have provided a very good website containing lots of impressive screen shots, demos and a good tutorial on how to create a Media Center Application using TWUIK.

It looks to be a very interesting product and I’ll certainly be downloading a trial copy …

Disk Drive Comfort Factor

Having spent several years developing software for large disk subsystems, I frequently found myself surrounded by racks and rack of noisy disk drives (or “disc” for the purists among you) often performing random seek tests in less than forgiving laboratory environments. Not for anyone who suffers from migraines I can tell you.

However, what I never really realised until recently was that there is somewhat of a subconscious comfort factor associated with the noise generated by a hard disk. As long there was a nice actuating noise coming from the disk (and not a high-pitched scratching noise), it at least meant that the system was still doing something and not hung.

I say this because I am currently in the process of carrying out some lengthy configuration of some new Solaris servers from a remote location (another room in the same building) which involves lots of slowly moving progress bars. I keep looking around for the system chassis to listen for disk activity (or look at a disk activity LED), all to comfort myself with the fact that the update is still progressing … but alas, nothing.

It’s a very strange feeling.