Rabu, 28 September 2016

How to login ssh keyless

  Tidak ada komentar

Step One—Create the RSA Key Pair

The first step is to create the key pair on the client machine (there is a good chance that this will just be your computer):
ssh-keygen -t rsa

Step Two—Store the Keys and Passphrase

Once you have entered the Gen Key command, you will get a few more questions:
Enter file in which to save the key (/home/demo/.ssh/id_rsa):
You can press enter here, saving the file to the user home (in this case, my example user is called demo).
Enter passphrase (empty for no passphrase):
It's up to you whether you want to use a passphrase. Entering a passphrase does have its benefits: the security of a key, no matter how encrypted, still depends on the fact that it is not visible to anyone else. Should a passphrase-protected private key fall into an unauthorized users possession, they will be unable to log in to its associated accounts until they figure out the passphrase, buying the hacked user some extra time. The only downside, of course, to having a passphrase, is then having to type it in each time you use the Key Pair.
The entire key generation process looks like this:
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/demo/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/demo/.ssh/id_rsa.
Your public key has been saved in /home/demo/.ssh/id_rsa.pub.
The key fingerprint is:
4a:dd:0a:c6:35:4e:3f:ed:27:38:8c:74:44:4d:93:67 demo@a
The key's randomart image is:
+--[ RSA 2048]----+
|          .oo.   |
|         .  o.E  |
|        + .  o   |
|     . = = .     |
|      = S = .    |
|     o + = +     |
|      . o + o .  |
|           . o   |
|                 |
The public key is now located in /home/demo/.ssh/id_rsa.pub The private key (identification) is now located in /home/demo/.ssh/id_rsa

Step Three—Copy the Public Key

Once the key pair is generated, it's time to place the public key on the virtual server that we want to use.
You can copy the public key into the new machine's authorized_keys file with the ssh-copy-id command. Make sure to replace the example username and IP address below.
ssh-copy-id [email protected]
Alternatively, you can paste in the keys using SSH:
cat ~/.ssh/id_rsa.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"
No matter which command you chose, you should see something like:
The authenticity of host ' (' can't be established.
RSA key fingerprint is b1:2d:33:67:ce:35:4d:5f:f3:a8:cd:c0:c4:48:86:12.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
[email protected]'s password: 
Now try logging into the machine, with "ssh '[email protected]'", and check in:


to make sure we haven't added extra keys that you weren't expecting.
Now you can go ahead and log into [email protected] and you will not be prompted for a password. However, if you set a passphrase, you will be asked to enter the passphrase at that time (and whenever else you log in in the future).

Optional Step Four—Disable the Password for Root Login

Once you have copied your SSH keys unto your server and ensured that you can log in with the SSH keys alone, you can go ahead and restrict the root login to only be permitted via SSH keys.
In order to do this, open up the SSH config file:
sudo nano /etc/ssh/sshd_config
Within that file, find the line that includes PermitRootLogin and modify it to ensure that users can only connect with their SSH key:
PermitRootLogin without-password
Put the changes into effect:
reload ssh

Senin, 26 September 2016

SymmetricDs Community Installation

  Tidak ada komentar

The important thing in symmetricDs are :

the source table :
sym_router, sym_trigger and sym_trigger_router                      

sym_router = the replication set from where to where
sym_trigger = define database that be synchronize
sym_trigger_router  = define the database in sym_trigger to use what method that declare in sym_router    

the rule for push or pull in : sym_node and sym_node_group_link

Don't forget to look at Sync.url and registration.url in properties file

for look at other replication datas that replicated can be found at sym_data

if the server was a push server, look at : sym_outgoing_batch                      

if the server was a pull server, look at : sym_incoming_batch and sym_incoming_batch_error                      
and the last are transaction not config

A node is represented by four tables:

Contains basic node information

Contains a single row that identifies the current node

Contains a password need to authenticate with another node

Contains informational data about the node. Updated by SymmetricDS.

Service in SymmetricDs

to install symmetricDs service :

bin/sym_service install

to uninstall symmetricDs service :

bin/sym_service uninstall

to start symmetricDs service :

bin/sym_service start

to stop symmetricDs service :

bin/sym_service stop

to check status symmetricDs service :

bin/sym_service status

Reset Mysql Password

  Tidak ada komentar

Stop the MySQL service

(Ubuntu and Debian) Run the following command:
sudo /etc/init.d/mysql stop
(CentOS, Fedora, and Red Hat Enterprise Linux) Run the following command:
sudo /etc/init.d/mysqld stop

Start MySQL without a password

Run the following command. The ampersand (&) at the end of the command is required.
sudo mysqld_safe --skip-grant-tables &

Connect to MySQL

Run the following command:
mysql -uroot

Set a new MySQL root password

Run the following command:
use mysql;

update user set password=PASSWORD("mynewpassword") where User='root';

flush privileges;


Stop and start the MySQL service

(Ubuntu and Debian) Run the following commands:
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
(CentOS, Fedora, and Red Hat Enterprise Linux) Run the following commands:
sudo /etc/init.d/mysqld stop
sudo /etc/init.d/mysqld start

Log in to the database

Test the new password by logging in to the database.
mysql -u root -p
You are prompted for your new password.

Minggu, 25 September 2016

IPTables Centos

  Tidak ada komentar

Iptables rules

There are 2 ways to configure iptables to open up port 80. First is using the iptables command and second is by creating a configuration file. First check the existing iptables rules in effect. The command is quite simple. Here is a sample output.
[root@dhcppc2 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@dhcppc2 ~]#
As can be seen in the output, there is a REJECT line in the INPUT chain at the end that says, reject all. However the previous line allows to accept ssh connections so ssh is working. A little more verbose and numeric list can be seen using the v and n options along with the L option
[root@dhcppc2 ~]# iptables --line -vnL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1      273 22516 ACCEPT     all  --  *      *             state RELATED,ESTABLISHED 
2        0     0 ACCEPT     icmp --  *      *             
3        0     0 ACCEPT     all  --  lo     *             
4        1    60 ACCEPT     tcp  --  *      *             state NEW tcp dpt:22 
5      271 36456 REJECT     all  --  *      *             reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1        0     0 REJECT     all  --  *      *             reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT 172 packets, 24494 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
[root@dhcppc2 ~]#

Open port 80

To accept http connections we need to add a rule at line number 5 and push the REJECT line below. Here is the command to do it.
# iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
The above command will add a rule at line #5 stating that the firewall should accept incoming connections on port 80. Check the iptables rules again.
[root@dhcppc2 ~]# iptables --line -vnL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1      291 23868 ACCEPT     all  --  *      *             state RELATED,ESTABLISHED 
2        0     0 ACCEPT     icmp --  *      *             
3        0     0 ACCEPT     all  --  lo     *             
4        1    60 ACCEPT     tcp  --  *      *             state NEW tcp dpt:22 
5        0     0 ACCEPT     tcp  --  eth0   *             tcp dpt:80 state NEW,ESTABLISHED 
6      286 38524 REJECT     all  --  *      *             reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1        0     0 REJECT     all  --  *      *             reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT 4 packets, 608 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
[root@dhcppc2 ~]#
Now we have the new tcp port 80 rule at line #5 and so now the http port is accessible from outer network.
However this change is temporary and would vanish if the server is rebooted. To make it permanent issue the iptables save command.
[root@dhcppc2 ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
The new rules are saved to the file /etc/sysconfig/iptables. Here is how the file looks
# Generated by iptables-save v1.4.7 on Fri Oct 25 10:33:46 2013
:OUTPUT ACCEPT [39:6956]
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
# Completed on Fri Oct 25 10:33:46 2013
Now the change is permanent.
Alternatively you could directly edit the iptables configuration file and restart iptables and the same change would take effect.
[root@dhcppc2 ~]# service iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[root@dhcppc2 ~]#

Install and Configure PhpMyAdmin Centos

  Tidak ada komentar
phpMyAdmin is an open source tool used for the administration of MySQL. In addition to offering the capability to perform administration tasks such as creating, editing, or deleting databases, and managing users and permissions, phpMyAdmin provides a graphical user interface to do all of these tasks and more.
Pre-Flight Check
  • These instructions are intended specifically for installing phpMyAdmin on CentOS 6.
  • I’ll be working from a Liquid Web Core Managed CentOS 6.5 server, and I’ll be logged in as root.
  • A LAMP, Linux, Apache, MySQL and PHP, must be installed on your server. If you’re working from a Liquid Web Core Managed CentOS 6.5 server as I am, then the LAMP stack is already installed!
Step 1: Add the EPEL Repository
phpMyAdmin is part of Extra Packages for Enterprise Linux (EPEL), which is a community repository of non-standard packages for the RHEL distribution. First, we’ll install the EPEL repository:
rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Step 2: Install phpMyAdmin
First, you’ll follow a simple best practice: ensuring the list of available packages is up to date before installing anything new.
yum -y update
Then it’s a matter of just running one command for installation via apt-get:
yum -y install phpmyadmin
Step 3: Find Your IP Address
Find your IP address with any of the following sites:
Step 4: Basic Configuration for phpMyAdmin
To secure phpMyAdmin we should lock down access to a specific IP address. When the phpMyAdmin package is installed, an Apache Virtual Host file is added to configure web access. Let’s edit that file:
vim /etc/httpd/conf.d/phpMyAdmin.conf
For a refresher on editing files with vim see: New User Tutorial: Overview of the Vim Text Editor
By default, the configuration for phpMyAdmin only allows access from the server on which it is installed. Find the following sections and change each IP address to the one you found in Step 3, or another IP address that will be connecting to phpMyAdmin remotely:
Require ip
Allow from
Require ip
Allow from
Then exit and save the file with the command :wq .
Restart Apache:
service httpd restart
Verify that phpMyAdmin is working by visiting http://the_IP_of_your_server/phpmyadmin. For example:

Disable SE-Linux Centos

  Tidak ada komentar
  1. Configure SELINUX=disabled in the /etc/selinux/config file:
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #       enforcing - SELinux security policy is enforced.
    #       permissive - SELinux prints warnings instead of enforcing.
    #       disabled - No SELinux policy is loaded.
    # SELINUXTYPE= can take one of these two values:
    #       targeted - Targeted processes are protected,
    #       mls - Multi Level Security protection.
  2. Reboot your system. After reboot, confirm that the getenforce command returns Disabled:
    ~]~ getenforce

Install Uninstall MySQL Packages

  Tidak ada komentar
Step 1: Uninstall MySQL Packages
First uninstall all the MySQL packages installed on your server
 # yum remove mysql mysql-server
Step 2: Romove MySQL Directory
Now we need to remove MySQL data directory from system which by default exists at/var/lib/mysql. If you didn’t find this, It may be changed to some other place, which you can find in my.cnf file with variable datadir. Delete the /var/lib/mysql directory from system but we prefer to rename it to keep a backup of existing files.
 # mv /var/lib/mysql /var/lib/mysql_old_backup
Step 3: Install MySQL Packages Again
After removing MySQL completely, install it again using yum package manager, It will re create mysql directory under /var/lib/.
# yum install mysql mysql-server
After completing above three steps, now you have a fresh MySQL install on your system with new settings.

Jumat, 23 September 2016

Download and install Oracle Java Centos 6.8

  Tidak ada komentar

Downloading Latest Java Archive

Java latest archive is available on its official site. We recommend to download latest version of Java from Oracle official website. After completing download also extract archive with given commands.

For 64 Bit:-

# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz"

# tar xzf jdk-7u79-linux-x64.tar.gz

For 32 Bit:-

# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-i586.tar.gz"

# tar xzf jdk-7u79-linux-i586.tar.gz
Note: If Above wget command doesn’t not work for you watch this example video to download java source archive using terminal.
Use archive file as per your system configuration. For this example we are using CentOS 7.0 (64 bit) system.
Install Java with Alternatives
After extracting Java archive file, we just need to set up to use newer version of Java using alternatives. Use the following commands to do it.
# cd /opt/jdk1.7.0_79/
# alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 2
# alternatives --config java
There are 3 programs which provide 'java'.

  Selection    Command
*  1           /opt/jdk1.7.0_60/bin/java
 + 2           /opt/jdk1.7.0_72/bin/java
   3           /opt/jdk1.7.0_79/bin/java

Enter to keep the current selection[+], or type selection number: 3 [Press Enter]
Now you may also required to set up javac and jar commands path using alternatives command.
# alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_79/bin/javac 2
# alternatives --set jar /opt/jdk1.7.0_79/bin/jar
# alternatives --set javac /opt/jdk1.7.0_79/bin/javac
Check Installed Java Version
Use following command to check which version of Java is currently being used by system.
# java -version

java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

Configuring Environment Variables
Most of Java based application’s uses environment variables to work. Use following commands to set up these variable properly. It’s also good to add following commands to any start-up script like ~/.bashrc or ~/.bash_profile.
  • Setup JAVA_HOME Variable
  • # export JAVA_HOME=/opt/jdk1.7.0_79
  • Setup JRE_HOME Variable
  • # export JRE_HOME=/opt/jdk1.7.0_79/jre
  • Setup PATH Variable
  • # export PATH=$PATH:/opt/jdk1.7.0_79/bin:/opt/jdk1.7.0_79/jre/bin

Senin, 19 September 2016

How to check Linux Version

  Tidak ada komentar
How to check Linux Version
a] /etc/*-release file.
b] lsb_release command.
c] /proc/version file.

Method #1: /etc/*-release file

To find out what version of Linux (distro) you are running, enter the following command at the shell prompt:
$ cat /etc/*-release
Sample output from my RHEL v5.x server:
Red Hat Enterprise Linux Server release 5 (Tikanga)
Sample outputs from my Ubuntu Linux v7.10 server:

Method #2: lsb_release Command To Find Out Linux Distribution Name/Version

The lsb_release command displays certain LSB (Linux Standard Base) and distribution-specific information. Type the following command:
$ lsb_release -a
Sample outputs:
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 6.0.1 (squeeze)
Release: 6.0.1
Codename: squeeze

How Do I Find Out My Kernel Version?

Type the following command:
$ uname -a
$ uname -mrs
Sample outputs:
Linux 2.6.32-5-amd64 x86_64
  1. Linux – Kernel name
  2. 2.6.32-5-amd64 – Kernel version number
  3. x86_64 – Machine hardware name (64 bit)

Say hello to /proc/version

Type the following command to see kernel version and gcc version used to build the same:
$ cat /proc/version
Sample outputs:
Linux version 3.2.0-0.bpo.1-amd64 (Debian 3.2.4-1~bpo60+1) ([email protected]) (gcc version 4.4.5 (Debian 4.4.5-8) ) #1 SMP Sat Feb 11 08:41:32 UTC 2012

How to check CentOS version

  Tidak ada komentar
There are several ways on how to check what version of CentOS is running on your system. Below you can find multiple examples on how to determine CentOS version. However, depending on your system not all examples may be applicable. First, example useshostnamectl command:
# hostnamectl 
   Static hostname: localhost.localdomain
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 6892999b8d8c43fab29fca961dbff24b
           Boot ID: b0a95bf56f61417ca8073b3847a73ab1
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-229.7.2.el7.x86_64
      Architecture: x86_64
The next example uses rpm command to to query for centos-release package to reveal CentOS version:
# rpm --query centos-release
Yet, another alternative is to use lsb_release command. However, this command is part of redhat-lsb package and is not installed by default so the actual lsb_release command may be unavailable on your system. If this is the case it is recommended to use some other alternative approach on how to check CentOS version on your system.
# lsb_release -d
Description:    CentOS Linux release 7.1.1503 (Core)
If none of the above does not reveal CentOS version we can try to query release numbers directly. Attempt to read the content of the following files to reveal CentOS version number:
  • /etc/centos-release
  • /etc/os-release
  • /etc/redhat-release
  • /etc/system-release
  • Use cat command to read their content in order to show CentOS version:
    # cat /etc/centos-release
    CentOS Linux release 7.1.1503 (Core) 
    # cat /etc/os-release
    NAME="CentOS Linux"
    VERSION="7 (Core)"
    ID_LIKE="rhel fedora"
    PRETTY_NAME="CentOS Linux 7 (Core)"
    # cat /etc/redhat-release
    CentOS Linux release 7.1.1503 (Core) 
    # cat /etc/system-release
    CentOS Linux release 7.1.1503 (Core)

Install Nmon in Centos

  Tidak ada komentar

Install Nmon in Centos

Download Nmon from here :


wget http://nchc.dl.sourceforge.net/project/nmon/nmon16e_x86_rhel72

sudo mv nmon16e_x86_rhel72 /usr/local/sbin/nmon

move to sbin directory :

cd /usr/local/sbin/

Show list of directory :

ls -l

Add excecution permitions to nmon :

chmod +x nmon 

Open nmon by typing nmon :