Friday, September 21, 2007

Htop in FreeBSD

I've always loved the top replacement named htop that's available in linux. I usually run my screen session with rtorrent, mc and htop opened. I was a bit dissapointed where the usually nitty-gritty method of installing software in FreeBSD (using the ports collection) has failed me when trying to get htop working on my server.
Here is a quick reminder for me (and everyone else for that matter) on how to get htop working on FreeBSD along with the linux compatibility layer.

First you have to dynamically load the linux object in the kernel:

kldload linux

Then we have to make this loading permanent so add linux_enable="YES" to /etc/rc.conf.

After this, install a linux layer:

cd /usr/ports/emulators/linux_base-fc4 (for some strange reason fc6 is not working for me)
make install distclean

Go to /etc/fstab and add the following line:

linproc /compat/linux/proc linprocfs rw 0 0

Mount the new filesystem: mount linproc and go to /usr/ports/sysutils/htop and install as usual.

As soon as I figure out a method of getting a screenshot from my box I will post it :D

Bye for now.

Sunday, September 9, 2007

Thwarting SSH Attacks

Oh my gosh! These SSH attacks are getting worse by the minute. A few months ago I found that one of my accounts on my desktop was hacked and was sponsoring bandwidth to some IRC bots and abusive scanning. The problem was that I had setup a user with a lame password for a friend of mine so he could get used to the linux command line. Even though I asked him to change the password, he didn't and that resulted in a complaint from a server to my ISP. Having investigated a little I found a huge auth.log with some brute-force attempts at ssh password.
Yesterday I started my ssh server on the laptop and because I was very busy I left the laptop running. Today I come home to find a 300K /var/log/auth.log file (which in my opinion - for a freshly installed box with 22h of uptime is a lot). Something had to be done. I hardened my sshd config and searched for something to throttle down the attacks.

Securing SSH

Installing ssh is a breeze. Just type pacman -S openssh, add sshd to your DAEMONS line in /etc/rc.conf.
Now let's take a look at our sshd config and see what we can do to harden our existing installation.
sudo vi /etc/ssh/sshd_config

  • Delete the comment before #Port 22 and let's give it something like 2222.
  • The protocol should be always set to Protocol 2 because Protocol 1 is insecure
  • LoginGraceTime 30
  • PermitRootLogin no. Actually it is better to disallow root from the securetty file (more on that later).
  • PasswordAuthentification no as you only want people to log in if they have a private key. (more on that subject later)
  • Banner /etc/issue.ssh - Put some text in this file - something like: Unauthorized access prohibited. Any activity will be logged.

Saturday, September 8, 2007

SSH attacks

Oh my gosh! These SSH attacks are getting worse by the minute. A few months ago I found that one of my accounts on my desktop was hacked and was sponsoring bandwidth to some IRC bots and abusive scanning. The problem was that I had setup a user with a lame password for a friend of mine so he could get used to the linux command line. Even though I asked him to change the password, he didn't and that resulted in a complaint from a server to my ISP. Having investigated a little I found a huge auth.log with some brute-force attempts at ssh password.
Yesterday I started my ssh server on the laptop and because I was very busy I left the laptop running. Today I come home to find a 300K /var/log/auth.log file (which in my opinion - for a freshly installed box with 22h of uptime is a lot). Something had to be done. I hardened my sshd config and searched for something to throttle down the attacks.

Saturday, September 1, 2007

Work in Progress

I'm sorry because I haven't updated this page in a very long time. The truth is I've been very busy going out on vacation and getting ready for my sister's wedding. Now I'm preparing my exams (I have failed several courses ... but that's okay) and after the 12th of September please check my blog out as I'm preparing some hot new stuff. I will be installing qmail on my FreeBSD server, securing it because it must go into production. New articles will pop out soon.