
Cast your vote go to : https://admin.fedoraproject.org/voting
Life of a geek.
station1
and the other is server1
. The station1
machine sends the log for local6
facility of any type of priority to server1
. But the log send over to server1
is going to be encrypted via stunnel package. Let's see how:-local6
log facility. First of all we will install the rsyslog
package which though comes with RHEL5.2 but is not the default:-
#yum install rsyslog
#service syslog stop
#yum remove sysklogd
#service rsyslog start
#chkconfig rsyslog on
#vi /etc/sysconfig/rsyslog
SYSLOGD_OPTIONS="-m 0 -t 61514"
#semanage port -a -t syslogd_port_t -p tcp 61514
#semanage port -l | grep syslogd_port_t
syslogd_port_t tcp 61514
syslogd_port_t udp 514
/etc/sysconfig/rsyslog
to semanage
. Note that all our setups have SELinux in enforcing mode so it's necessary that we take proper care of SELinux.
#service rsyslog restart
#iptables -A MYCHAIN -p tcp --dport 60514 -j ACCEPT
#service iptables save
stunnel
installed.
#cd /etc/stunnel
#cp /usr/share/doc/stunnel-4.15/stunnel.conf-sample stunnel.conf
; Certificate/key is needed in server mode and optional in client mode
cert = /etc/stunnel/stunnel.pem
key = /etc/stunnel/stunnel.key
; Some security enhancements for UNIX systems - comment them out on Win32
chroot = /var/run/stunnel/
setuid = nobody
setgid = nobody
; PID is created inside chroot jail
pid = /stunnel.pid
; Some performance tunings
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
; Authentication stuff
verify = 2
; It's often easier to use CAfile
CAfile = /etc/stunnel/cacert.pem
; Service-level configuration
[ssyslog]
accept = 60514
connect = 61514
[ssyslog]
specify which port stunnel will listen to and then which port it will forward the connection too. The destination port is of the local interface (127.0.0.1) as far as I know, haven't digged much into it so I am not sure. Please feel free to comment on it./stunnel.pid
but that's relative to /var/run/stunnel
now, after that we had some performance tuning options which actually came enabled default in the sample conf file so I thought of keeping them up, after that verify=2
is used to verify the other end of the tunnel, the verification is done by checking the security certificate of the other end of the tunnel upto depth level 2 so that checks whether the security certificate of the other end (the client end, in our case station1) is actually signed by the same Certificate Authority (CA) as the one specified by the next option that is CAfile
.
#mkdir /var/run/stunnel
#chown nobody:nobody /var/run/stunnel
/etc/stunnel
for configuration purposes. The following command helped in the above task:-
#cd /etc/stunnel
#openssl genrsa -out stunnel.key 2048
#openssl req -new -key stunnel.key -out stunnel.csr
#scp stunnel.csr root@certificate.example.com:/etc/pki/CA
certificate.example.com
we issued the following commands:-
#cd /etc/pki/CA
#openssl ca -in stunnel.csr -out stunnel.pem
#scp stunnel.pem cacert.pem root@server1.example.com:/etc/stunnel/
#rm -f stunnel.*
#chown root:root /etc/stunnel/*
#chmod 600 /etc/stunnel/*
stunnel
.
#stunnel
#ps aux | grep stunnel
nobody 4476 0.0 0.3 5060 984 ? Ss 16:46 0:00 stunnel
/etc/rc.d/rc.local
of your system (at the bottom):-
/usr/sbin/stunnel
server1
is done and now it's time to proceed at the client side.server1
installing rsyslog package and removing the stock sysklogd
package via the following commands:-
#yum install rsyslog
#service syslog stop
#yum remove sysklogd
#service rsyslog start
#chkconfig rsyslog on
#cd /etc/stunnel
#cp /usr/share/doc/stunnel-4.15/stunnel.conf-sample stunnel.conf
; Certificate/key is needed in server mode and optional in client mode
cert = /etc/stunnel/stunnel.pem
key = /etc/stunnel/stunnel.key
; Protocol version (all, SSLv2, SSLv3, TLSv1)
sslVersion = SSLv3
; Some security enhancements for UNIX systems - comment them out on Win32
chroot = /var/run/stunnel/
setuid = nobody
setgid = nobody
; PID is created inside chroot jail
pid = /stunnel.pid
; Some performance tunings
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
; Authentication stuff
verify = 2
; It's often easier to use CAfile
CAfile = /etc/stunnel/cacert.pem
; Use it for client mode
client = yes
; Service-level configuration
[ssyslog]
accept = 127.0.0.1:61514
connect = 192.168.122.2:60514
client = yes
that differentiates server end and client end in a stunnel.
#mkdir /var/run/stunnel
#chown nobody:nobody /var/run/stunnel
#cd /etc/stunnel
#openssl genrsa -out stunnel.key 2048
#openssl req -in -key stunnel.key -out stunnel.csr
#scp stunnel.csr root@certificate.example.com:/etc/pki/CA
certificate.example.com
the following commands were issued:-
#cd /etc/pki/CA
#openssl ca -in stunnel.csr -out stunnel.pem
#scp stunnel.pem cacert.pem root@station1.example.com:/etc/stunnel
#rm -f stunnel.*
#chown root:root /etc/stunnel/*
#chmod 600 /etc/stunnel/*
stunnel
. If we want to start the tunnel automatically on every boot up it's simple just add the line /usr/sbin/stunnel
in /etc/rc.d/rc.local
at the end. To verify that stunnel is running properly or not just issue the old command ps aux | grep stunnel
and see if there is any process owned by user nobody
with the name stunnel.local6
facility to 127.0.0.1:61514
where stunnel will read them up and send them to 192.168.122.2:60514
. Note here that 192.168.122.2
is actually server1
but instead of specifying the name I preferred IP address as DNS can be un-available in my setup./etc/rsyslog.conf
:-
local6.* @@127.0.0.1:61514
#service rsyslog restart
logger -i -p local6.info -t deependra "This is a test log message sent over stunnel"
/var/log/messages
as
Jul 28 18:24:30 station1 deependra[3460]: This is a test log message sent over stunnel
/etc/ntp.conf
first.
mv /etc/ntp.conf /etc/ntp.conf.bak
/etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 stratum 1
crypto pw redhat randfile /dev/urandom
keysdir /etc/ntp
restrict default ignore
restrict 127.0.0.1
restrict 192.168.122.0 mask 255.255.255.0 nomodify noquery
driftfile /var/lib/ntp/drift
crypto
line which tells that my ntpkey files are protected with a password redhat
and that the filesource which is used for generating random seed data is /dev/urandom
. Note that the password attribute is a important one so this file which /etc/ntp.conf
should have a strict permission.
#chmod 640 /etc/ntp.conf
#chown root.ntp /etc/ntp.conf
/etc/ntp/crypto
but I used /etc/ntp
which is default in RHEL 5./etc/ntp
and generate the host keys and IFF parameters as we are going to use IFF identity scheme in this setup.
#cd /etc/ntp
#ntp-keygen -T -I -p redhat
redhat
that we also mentioned in /etc/ntp.conf
. The list of files which were generated in my case are listed below
ntpkey_cert_station1.example.com
ntpkey_IFFpar_station1.example.com.3426211635
ntpkey_RSA-MD5cert_station1.example.com.3426211635
ntpkey_host_station1.example.com
ntpkey_iff_station1.example.com
ntpkey_IFFkey_station1.example.com.3426211635
ntpkey_RSAkey_station1.example.com.3426211635
#ntp-keygen -e -q redhat -p linux > ntpkey_IFFkey_station1.example.com.3426211635
#scp ntpkey_IFFkey_station1.example.com.3426211635 root@server1.example.com:/etc/ntp
#service ntpd start
#chkconfig ntpd on
#iptables -A MYCHAIN -p udp --dport 123 -j ACCEPT
#service iptables save
/etc/ntp.conf
#chmod 640 /etc/ntp.conf
#chown root.ntp /etc/ntp.conf
#vi /etc/ntp.conf
server station1.example.com iburst autokey
crypto pw linux randfile /dev/urandom
keysdir /etc/ntp
station1.example.com
aka 192.168.122.1
. The option autokey enables the use of public key cryptography. The next line specify the crypto password with which the client ntpkey_* files will be protected and also specify the random seed source to be used. Next line specify where to find the key data.
#cd /etc/ntp/
#ntp-keygen -H -p linux
#ln -s ntpkey_IFFkey_station1.example.com.3426211635 ntpkey_iff_station1.example.com
#ln -s ntpkey_host_server1.example.com ntpkey_iff_server1.example.com
linux
and next create some symlinks which later configure the IFF keys at the client side. Note here that the file ntpkey_IFFkey_station1.example.com.3426211635
was sent by the time server which was protected by the password linux
./etc/ntp
were finally:-
ntpkey_cert_server1.example.com
ntpkey_host_server1.example.com
ntpkey_IFFkey_station1.example.com.3426211635
ntpkey_iff_server1.example.com
ntpkey_iff_station1.example.com
ntpkey_RSAkey_server1.example.com.3426211933
ntpkey_RSA-MD5cert_server1.example.com.3426211933
#ntpdate -b station1.example.com
#service ntpd start
#chkconfig ntpd on
#iptables -A MYCHAIN -p udp --dport 123 -j ACCEPT
#service iptables save
#ntpq -cas
ind assID status conf reach auth condition last_event cnt
===========================================================
1 28241 f624 yes yes ok sys.peer reachable 2
#ntpq -c"rv 0 cert"
assID=0 status=0664 leap_none, sync_ntp, 6 events, event_peer/strat_chg,
cert="server1.example.com station1.example.com 0x6",
expire=200907280654,
cert="station1.example.com station1.example.com 0x7",
expire=200907280527, cert="server1.example.com server1.example.com 0x2",
expire=200907280532
#ntpq -c"rv 28241 flags"
assID=28241 status=f624 reach, conf, auth, sel_sys.peer, 2 events, event_reach,
flags=0x83f21
0x83f21
that signifies that the communication with the time server was successful and that IFF identity scheme with cryptography enabled was used.ntpq,ntptrace,ntpdate,nptdc,ntpstat
etc.