SSH Public key based authentication

Method-1:

Create the cryptographic Key on FreeBSD / Linux / UNIX workstation, enter:

ssh-keygen -t rsa
Assign the pass phrase (press [enter] key twice if you don’t want a passphrase). It will create 2 files in ~/.ssh directory as follows:
  • ~/.ssh/id_rsa : identification (private) key
  • ~/.ssh/id_rsa.pub : public key
Use scp to copy the id_rsa.pub (public key) to rh9linux.nixcraft.org server as authorized_keys2 file, this is know as Installing the public key to server.
 
scp .ssh/id_rsa.pub vivek@rh9linux.nixcraft.org:.ssh/authorized_keys2
 
From FreeBSD workstation login to server:

Read more

Share

Install Sun Java 7.x on Debian Squeeze

It might look weird to install Sun Java from a Ubuntu Repo- however it works at least it worked for my installation-

$ su root
# echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" > /etc/apt/sources.list.d/webupd8team-java.list
# echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" >> /etc/apt/sources.list.d/webupd8team-java.list
# apt-key adv –keyserver keyserver.ubuntu.com –recv-keys EEA14886
# apt-get update
# apt-get install oracle-java7-installer
# java -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
# exit
$

Share

Install VNCServer on Centos 5

 

Install VNC Server to operate CentOS with GUI remotely from Windows client. VNC is already installed if you already build Desktop Environment. If it's not installed, Install by a command 'yum -y install vnc-server'.
[root@ns ~]# yum -y install vnc-server
[root@ns ~]# vi /etc/sysconfig/vncservers
# line 20: make valid and set as '(diplay number):(user name)' like follwing example
VNCSERVERS="1:cent"
# line 21: uncomment and remove '-localhost' like below
# And set any screen resolution you like
VNCSERVERARGS[1]="-geometry 1024×768 -nolisten tcp -nohttpd"
[root@ns ~]# su – cent
[cent@ns ~]$ vncpasswd# set VNC password

Read more

Share

Installing LAMP On Debian

First we install MySQL 5 like this:

apt-get install mysql-server mysql-client
You will be asked to provide a password for the MySQL root user – this password is valid for the user root@localhost as well as root@server1.example.com, so we don't have to specify a MySQL root password manually later on:
New password for the MySQL "root" user: <– yourrootsqlpassword
Repeat password for the MySQL "root" user: <– yourrootsqlpassword

Read more

Share

Importing Big mysqldump with Progress Bar PV

 

I am using CentOS 6.4 box, so it requires me to install EPEL repo at the first place:
$ rpm -Uhv http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Install pv using yum:
$ yum install -y pv
Installation done. Let the importing begin!
$ pv /home/user/my_big_dump.sql | mysql -uroot -p
For Ubuntu/Debian distribution intall PV using-
apt-get install pv
 
Share

OpenVZ on Debain Squeeze

 

As soon as your Debian OS server is ready, login using the received credentials. We first will do an update/upgrade:
apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade
which will upgrade our server to latest version.
We install some additional packages to:
apt-get -y install nano wget ntp ntpdate
Installing OpenVZ
We now want to install OpenVZ, the base for our virtual multiserver environment.
An OpenVZ kernel and the vzctl, vzquota, and vzdump packages are available in the Debian Squeeze repositories, so we can install them as follows:
apt-get install linux-image-openvz-amd64 vzctl vzquota vzdump
Create a symlink from /var/lib/vz to /vz to provide backward compatibility:
ln -s /var/lib/vz /vz
Open /etc/sysctl.conf and make sure that you have the following settings in it:
nano /etc/sysctl.conf
[…]
net.ipv4.conf.all.rp_filter=1
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.default.forwarding=1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.ip_forward=1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.eth0.proxy_arp=1
[…]
If you needed to modify /etc/sysctl.conf, run
sysctl -p
The following step is important if the IP addresses of your virtual machines are from a different subnet than the host system's IP address. If you don't do this, networking will not work in the virtual machines!
Open /etc/vz/vz.conf and set NEIGHBOUR_DEVS to all:
nano /etc/vz/vz.conf
[…]
# Controls which interfaces to send ARP requests and modify APR tables on.
NEIGHBOUR_DEVS=all
[…]
Finally, reboot the system:
reboot
If your system reboots without problems, then everything is fine!
Run
uname -r
and your new OpenVZ kernel should show up:
root@root:~# uname -r 
2.6.32-5-openvz-amd64
Since Hetzner mounts /home on a separate hard disk, we can use it as the OpenVZ backup location. To do so, run:
rm -rf /var/lib/vz/dump 
ln -s /home/backup/vz /var/lib/vz/dump
As we will use fail2ban within our virtual containers, we have to enable some IPTables support for them. We do that by editing the /etc/vz/vz.conf file:
nano /etc/vz/vz.conf
Search the line starting with IPTABLES and comment it (#). Paste the following afterwards:
[…]
IPTABLES="ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state"
Next, active the state module in the kernel:
modprobe xt_state
Installing OVZ Web Panel
The OpenVZ Web Panel is a GUI web-based frontend for controlling of the hardware and virtual servers with the OpenVZ virtualization technology.
The most simple way to install OpenVZ Web Panel is to run the following command:
wget -O – http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh
After installation Panel should be available by the following URL:
http://<192.168.1.1>:3000
Default administrator's credentials are: admin/admin. Don't forget to change default password.
Creating The Virtual Servers
We now will use the OVZ Web Panel to create our virtual servers. Log into the panel and add your IPs under IP Addresses. Then, click on localhost and OS Templates.
We now have to download a template for our virtual servers. We do so by clicking Install New OS Template -> Contributed and select debian-6.0-amd64-minimal.
Now go back to localhost and click Create virtual server. Fill in the fields as below:
Server ID (VEID): a number (I would choose the last part of you IP, so 2 for the first)
OS Template: already selected the right
Server Template: unlimited
IP Address: 192.168.1.2
Host Name: web.example.tld
DNS Server: 8.8.4.4 8.8.8.8 (which are Google's DNS)
leave the rest as it is and assign Disk Space, RAM and CPU like you want…
Src:
http://www.howtoforge.com/virtual-multiserver-environment-with-dedicated-web-mysql-email-dns-servers-on-debian-squeeze-with-ispconfig-3-p2
https://code.google.com/p/ovz-web-panel/
Share

TimeZone adjust in Linux

 

For Redhat/CentOS/Fedora/SL distribution
Type the redhat-config-date command at the command line to start the time and date properties tool, run:
# redhat-config-date
OR type setup and select time zone configuration. This tool is recommended for remote ssh text based sessions.
# setup
Select timezone configuration. Just follow on screen instructions to change the timezone.
If you are using Debian / Ubuntu Linux
To change the timezone for you run the following command as root user:
# dpkg-reconfigure tzdata
Again, just follow on screen instructions.
Share

Update PHP 5.1 to PHP 5.4 in CentOS

 

Update Yum repos
For 32 bit CentOS-
For 64 bit CentOS-
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
Now it’s time to update our PHP to the latest one
yum –enablerepo=remi update php php-*
/etc/init.d/httpd restart
And that’s it!
You can check your installed PHP version executing:
php -v
Share

LAMP on CentOS

Installing MySQL 5

To install MySQL, we do this:

yum -y install mysql mysql-server

Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:

chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start

Set passwords for the MySQL root account:

Read more

Share