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.

Tuesday, July 17, 2007

Archlinux setup tutorial

Today I am going to write a quick tutorial on installing and getting a working system using Archlinux. I believe that this is one of the best distributions available, if you are willing to work and start learning something about the fascinating Linux world. As a Slackware user for almost 5 years, I recently switched to Arch because I think that it has some very interesting features that lack in Slack, such as a great package manager and platform specific compiling (it is built for the i686 platform). You get all the nifty features like bleeding-edge packages and standard 2.6 kernel (hehe slack) but you still control the operating system. So, without further ado, let us begin.

Getting the ISOs

I just grabed a copy from my local mirror and burned it on a CD. I only got the base system iso as it is faster to download and I always get packages through pacman. Leave the CD in the tray and reboot your system. Following the instructions on the screen you should get a command prompt:

[Arch Linux: /]#

Partitioning

I have my hdd already partitioned and I won't get into technical stuff such as partitioning your drive. You get fdisk and cfdisk for that and there are plenty of tutorials available on google for such. Anyway, here is my hdd layout:

/dev/sda5 - / - 10GB
/dev/sda6 - /boot - 1GB
/dev/sda7 - swap - 3GB (I know that it's not necessary to have such a big partition for swap but I also use my box as a server)
/dev/sda8 - /usr - 15GB
/dev/sda9 - /home - 15GB (you will download por.... ahem ... pro... grams won't you :) )

Basic setup

Okay. At the prompt just type in /arch/setup and you should be welcomed by a dialog based installation program.

1. You are prompted to choose your installation media. I usually (I mean always) go for option 1 - CD-ROM or OTHER SOURCE

2. Prepare hard drive

  • I only go for option 3 and assign mount points to my partitions. I choose ext3 for my filesystem although I believe that xfs is better than ext3 (bad habits die hard).
  • Be careful that you first have to choose your swap partition.
3. Select packages. As I only downloaded the base ISO, guess how many options I have:)
4. Install packages - pretty straightforward. I do not choose to keep the packages in cache as I won't have any further use for them.
5. Configure system - use nano or vi to your liking (I recommend nano if you want just easy editing)
  • Use hwdetect
  • No booting from usb devices (at least in my case)
  • No fireware
  • No pcmcia devices
  • No nfs shares
  • No software raid arrays
  • No lv2m
  • No encrypted volumes
  • No custom DSDT files
  • /etc/rc.conf - this is your general config file so be careful what you write in it
  1. Timezone - i change mine to Europe/Bucharest
  2. MOD_BLACKLIST=(nvidiafb) - I add this since nvidiaframe buffer gives me an error while trying yo compile my nvidia graphic card
  3. HOSTNAME="something"
  4. Modify eth0="eth0 ip_address netmask subnet_address broadcast broadcast_address"
  5. Modify gateway with your default gateway and be sure to delete the preceding ! on ROUTES=(!gateway) as this disables the gateway (nasty)
  • hosts - add your host that you put in the HOSTNAME variable in /etc/rc.conf (above)
  • /etc/resolv.conf - add your nameservers or you can just opendns
  • locale-gen - uncomment the line with en_US.UTF-8
  • Set the root password
  • Choose the mirror closest to you
6. Install the kernel - you only have one option here too
7. GRUB is okay for me - but I have to uncomment the Windows lines :-S... sorry guys ... hem... not me :)

Now go ahead and reboot. All should be fine.

Adding a user

Just type adduser at the command prompt and follow the instructions on the screen. Please be advised that I use a sudo environment and as such, a good password for the username is necessary.

Upgrading the system

just run pacman -Syu at the command prompt. It will take a while (not that much really because there aren't so many packages installed yet).

Sudo environment

As I believe that the Ubuntu philosophy regarding using sudo is very good, on all my systems I get sudo up and running. Here is how:

pacman -S sudo
Run visudo after that and just below root ALL=(ALL) ALL add user ALL=(ALL) ALL. Be careful please as this implies that the specified user will have all the privileges root has.

Xorg setup

It is as simple as

sudo pacman -S xorg

After that all you need to do is generate an /etc/X11/xorg.conf. I like the nvidia setup tool for Xorg so let's go ahead and install some proprietary drivers.

sudo pacman -S nvidia
sudo nvidia-xconfig
cp /etc/skel/.xinitrc ~

Now let's edit the xinitrc file and delete the comment before exec startkde (as we will be using kde).

KDEMOD

Kdemod is a modular and patched version of KDE for Archlinux. It's really great. All you need to do is to edit the pacman file:

sudo vi /etc/pacman.conf
Add at the end
[kdemod]
Server = http://kdemod.ath.cx/repo/current/i686
sudo pacman -Syu
to get the list for the kdemod repository
sudo pacman -S kdemod - go get a cup of coffee or something as this surely takes a while
sudo pacman -S kdemod-kdebase-kickoff
sudo pacman -S kdemod-kdebindings
sudo pacman -Rd libbeagle
sudo pacman -S kdemod-kerry
sudo pacman -S kdemod-beagle
sudo pacman -S kdemod-applets kdemod-tools
sudo pacman -S kdemod-kdeutils-kcalc kdemod-kdeadmin
sudo /opt/kde/bin/apply_kdemod_theme


Accessing your NTFS partition

Okay guys I'm guilty. I do have some ntfs partitions on my desktop. Here is how to access them:

sudo pacman -S ntfs-3g
sudo modprobe fuse
Add fuse to your /etc/rc.conf MODULES part
Edit your /etc/fstab file
Add the line:
/dev/sda1 /mnt/sda1 ntfs-3g defaults 0 0
And then let's remount all the drives (but be sure to create /mnt/sda1 first)
You now have read-write access to your ntfs drives.

Let's listen to some music

sudo pacman -S alsa-utils alsa-lib alsa-oss
sudo alsaconf
sudo alsamixer
sudo alsactl store
gpasswd -a user audio

Also be sure to add alsa to the DAEMONS line in /etc/rc.conf (you have to edit it as root).

Tips and tricks

  • Let users use usb sticks
gpasswd -a user storage
gpasswd -a user optical
  • Settings for firefox:
Proportional: Serif 16
Serif: Times New Roman
Sans: Arial
Monospace: Courier New 13
Minimum font size: 13
  • Settings for KDE
Go to Control Center. Replace color with cleanstick-black-font (you can find it on kde-look.org). Replace style and Window Decorations with Plastik.

  • Add hal to DAEMONS in /etc/rc.conf

Software ( great stuff to install )

sudo pacman -S firefox
sudo pacman -S ttf-msfonts ttf-cheapskate artwiz-fonts
sudo pacman -S amarok-base
sudo pacman -S rtorrent
sudo pacman -S acroread
sudo pacman -S jre
sudo pacman -S openoffice-base
sudo pacman -S screen
sudo pacman -S smplayer
sudo pacman -S flashplugin
sudo pacman -S pidgin

Well that's about it for tonight. Tomorrow we take a look at some of the config files for different programs. Yes I admit most of this stuff you could find on the Archlinux Wiki but I thought that bringing all of these together combined with my own experience of using Archlinux could be somewhat interesting.