Sunday, November 6, 2011

Change the default SSH port on Linux

OpenSSH server uses TCP Port 22 by default.Since, it is a common target for hackers and brute-forces, it is a good practice to change the port to something higher.Let's assume that we want to change the port to 2222, then as root,

nano /etc/ssh/sshd_config


Edit the line which says Port 22 to Port 2222.

Do remember that the port should not be in use by another program or service.Now,restart SSH server via

service ssh restart


You may want to setup your IPtables rules or other firewall rules to allow incoming TCP packets in port 2222.In case you are using ufw ,you would do ,

ufw allow 2222/tcp

Tuesday, November 1, 2011

Setup Static IP Address on Debian 6 (Squeeze)

During installation, Debian uses DHCP by default.You should disable DHCP feature for primary network interface by editing /etc/network/interfaces
By default, it looks like following:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo
inet loopback


# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp



We should make this look like:


# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo
inet loopback


# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.1
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1



You may not need to enter network and broadcast details.
Now, restart service by 
/etc/init.d/networking restart

Installing Virtualmin on Debian 6 (Squeeze)

I am using Debian Squeeze for installing Virtualmin. So, here are the steps:


Step 1 : Fresh Install Your System
Virtualmin installs everything for you.No particular partitioning is required.


Step 2 : Set up Fully Qualified Domain Name for your System
Refer to http://linuxdo.blogspot.com/2011/11/fully-qualified-domain-name-on-debian.html


Step 3 : Download Virtualmin Installer Script
Available at http://software.virtualmin.com/gpl/scripts/install.sh

Step 4 : Run the script
sh ./install.sh



In minutes, everything will be installed and you can access the Control Panel on https://[your-ip]:10000 . And then log in as the "root" user, or any user with sudo access.



Fully Qualified Domain Name on Debian Squeeze

Debian uses a simple FQDN approach by getting the values from hosts file.So, if you would like to set up ns1.example.com as a FQDN for your server, then modify /etc/hosts file so it looks like

127.0.0.1 localhost 127.0.1.1 ns1.example.com ns1 # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts

Other values may depend on your system.