Archive for September, 2010

Create and work with compressed files

Sunday, September 19th, 2010

Creating and working with compressed files in FreeBSD server is an easy task.

to compress a file you can use

#gzip filename

to compress each file in a directory,each file will be compressed in one file.

#gzip -r directory-name

to compress all files in a single archive:

#tar -zcvf  archive-name.gz directory-name.

to uncompress an archive:

#tar -zxvf archive-name.gz -C /directory-name

also to uncompress an archive:

#gzip -d archive.gz

to uncompress each file in a directory use

#gzip -d folder-name

Install Mono on FreeBSD step by step

Saturday, September 18th, 2010

Mono is the Microsoft .net framework ported Open Source world and consists of runtime environment, compiler, and web server for handling ASP.NET web sites.

First step is install or update ports collection  using “#portsnap fetch”, then “#portsnap extract” or “#portsnap update”.

#cd /usr/ports/lang/mono

#make install clean
Then follow the configuration and setup options.

It will take some time to build, after installation, and build complete you can start your first c# application

#ee hellowolrd.cs

class Program
{
static void Main(string[] args)
{
System.Console.WriteLine(“Hello world, server time is:{0}”,System.DateTime.Now.ToString());
}
}

save the file and exit.

compile the file using mono compiler:

#/usr/local/bin/mcs hellowolrd.cs -r:System.Web.dll -r:System.Data.dll

run the hellowolrd application using:

# /usr/local/bin/mono helloworld.exe


What To Do when receive FreeBSD Dedicated Server from Hosting Company

Saturday, September 18th, 2010

First of all you should be happy that you received your FreeBSD dedicated box.

Change passwords for  ssh admin login user, and root user, you can use command passwd.
Add more login users if you like.

It’s recomended to change the default ssh port 22 to something else to protect from spam.

Download and extract Ports Collection using commands:

  1. #portsnap fetch
  2. #portsnap extract

If Ports Collection already installed you can update it using :

  • #portsnap update

Update locate database lookup file to make it easy find and search files using command:

  • #/usr/libexec/locate.updated.

Start setup other software you need.
you cane use locate to find it for example search and install apache web server:
#locate apache

#cd /usr/ports/www/apache22

#make install

Change Default SSH Port to Protect FreeBSD server from daily spam attack

Saturday, September 18th, 2010

Change Default SSH Port to Protect your FreeBSD server from daily spam attack.

# ee /etc/ssh/sshd_config

look for line #port 22 and change it to port 1234 then press Esc, save and exit.

reboot the server

#shutdown -r now

or type this command to reload SSH

# /etc/rc.d/sshd reload

Create a new user and Change User Password

Saturday, September 18th, 2010

To Add a new user you can use adduser command, and it ask you for user information step by step.

To Change user password use passwd command

Example

#passwd Joo –> will let you change the password for user Joo.

#passwd  –> will let you change the password for current user.

Building secure Email Server

Wednesday, September 15th, 2010

FreeBSD comes by default with sendmail email server installed, but its not secure and scalable enough.

Building secure Email Server from scratch is a huge task, because it need many component to be installed and configured.

My objective was to build a secure, fast, reliable email server, very less and optimized system resource, using SSL, have a web interface for administration, web interface for clients, can be accessed by email clients application like Microsoft outlook and Microsoft outlook express, also my email server should be protected against spam and virus scan capabilities.

Secure Email Server component include:

  • Install and configure Apache  server.
  • Install and configure PHP.
  • Install and configure MySql server.
  • Create SSL/TLS certificate using openssl.
  • Install and configure Dovecot POP3/IMAP server.
  • Install and configure PostFix the alternative to Sendmail.
  • Install and configure PostFixAdmin.
  • Install and configure squirrelmail.
  • Install and configure SpamAssassin.

one of the best articles I found on the web, which go step by step to install a secure email server on FreeBSD here