Archive for January, 2018

How to install Oracle VirtualBox and create a CentOS 7 VM

Hi,

Jyoti Sensharma

Generally for testing new components, services or products we frequently need VM machines. Specially for testing open source components. Hence we need some kind of virtualbox setup locally to test these things quickly. Oracle VirtualBox is a general-purpose full virtualiser for x86 hardware, targeted at server, desktop and embedded use.

In this article we will see how quickly we can configure the Oracle VirtualBox and create a CentOS 7 VM. The same article can be referred to create any other OS VM like RHEL 6/7, Fedora, Suse etc

 

Download the Oracle VirtualBox from below link and install:
https://www.virtualbox.org/wiki/Downloads

Download CentOS 7 minimal version from below link:
http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1708.iso

Global VirtualBox Network Settings

In below steps we will add a new NAT Network and Host-Only Network which will help our VMs to get a public IP Address and they will be able to connect to the world wide network.

Step1: Navigate to VirtualBox >> Preferences >> Network

Step2: Add a new NAT Network.

Step3: Navigate to File >> Host Network Manager

Step4: Add a new Host-Only Network.

VM creation and its network settings

Step5:  Create a new VM in VitualBox with Type Linux for installing CentOS 7.

Step6: Setting 4GB RAM for this VM so that we can run some servers on this VM and test multiple things at a time.

Step7: In this stage we are fixing the memory utilisation of this VM by selecting Fixed Size, so that it should not consume more than the allocated memory.

Step8: Allocating 20GB memory for the hard disk of this VM

Step9:  Configure the network settings for this CentOS 7 Node1 vm as follows:

Step10: Start this node1 and install CentOS 7 in this vm.

Step11: Just in case if you want to make the IP Address Static “192.168.56.101” and IPV6 disabled then follow the below steps:

vi /etc/sysconfig/network-scripts/ifcfg-enp0s8

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s8
UUID=58c59ff3-31fa-4fa4-8259-430e5e122d52
DEVICE=enp0s8
ONBOOT=yes
IPADDR=192.168.56.101

Step12: Restart the network services:

service network restart

Step13: Repeat the above steps of “VM creation and its network setting” to create Node2.

Configure both the host to recognise each other by their hostnames:

Edit the “/etc/hosts” file:

vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.56.101	node1.example.com
192.168.56.102	node2.example.com

For Configuring passwordless ssh between these nodes refer the below article:

How to configure passwordless ssh between linux hosts


How to configure passwordless ssh between linux hosts

Jyoti Sensharma

Hi,
Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. The best known example application of ssh is for remote login to computer systems by users. It is also used while doing an SCP to transfer files from one host to another host over the network.

SSH provides a secure channel over an unsecured network in a client-server architecture, connecting an SSH client application with an SSH server. Common applications include remote command-line login and remote command execution, but any network service can be secured with SSH.

In this article we are going to learn how we can do a passwordless ssh from one linux host to another. By default when we do a ssh to a remote linux host it asks for a password, but entering a password every-time you do a ssh becomes time consuming. Therefore there is a way to generate a ssh key and configure other linux hosts to achieve this functionality.

Default ssh command to connect a linux host and its output

[root@node1 ~]# ssh root@node2.example.com
The authenticity of host 'node2.example.com (192.xx.xx.102)' can't be established.
ECDSA key fingerprint is SHA256:PMG2xSYmdcdkzdgXV7Nw3Jtzd0NzbLmBmXlaQEzHEQ.
ECDSA key fingerprint is MD5:aa:d5:b9:33:7e:a6:32:as:xx:0c:20:1f:55:f3:00:1e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node3.example.com,192.xx.xx.102' (ECDSA) to the list of known hosts.
root@node2.example.com's password: 
Last login: Thu Jan  4 11:23:09 2018 from 192.xx.xx.102
[root@node2 ~]# 

Steps to configure passwordless ssh to a linux host

Step1: Generate a ssh key on node1 using “ssh-keygen” utility.

[root@node1 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:eb691XAY0MVxsswolHv7xhGwbr2uX7e8vZ0uOwhisrwA root@node1.example.com
The key's randomart image is:
+---[RSA 2048]----+
|            oox++|
|             =.oo|
|            . + .|
|         .   . =x|
|   E    S . . @ o|
|    .    =   o +.|
|     .  . = o =.=|
|      .. . * +=O=|
|       .o.. +o*@X|
+----[SHA256]-----+

Step2: Copying public ssh key of node1 to node2 using “ssh-copy-id” utility.

[root@node1 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node2.example.com
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node2.example.com's password: 
Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@node2.example.com'"
and check to make sure that only the key(s) you wanted were added.

Step3: Verify the key entry in the node2 in file ~/.ssh/authorized_keys

[root@node2 ~]# less ~/.ssh/authorized_keys

ssh-rsa AAAAB3NzaC1c2EAAAADAQABAAABAQDUnkqPN1LVvyJkiIXnabmoN4hmL3WfuDcrWwURCqVAkwG0+00DEiiUXuwUL3gGDXaKpJxxJKsP1RthFtxw1Fl9OJ1QKB6m0S2CgyP5RkmFq2PwEUxyFvAXXOaHAfvISadv55mRP3iTGAUEfnQGz0wQXXLruBC4NbF27R8h1Wqx+AwS+X+qLXDjLjR3pRXQtaWDGYsLGCXN4zOovdaYN1SjqSkg23oxI/rQl9z/4nf8CZZyKM+9lYN+2wBe99PPjHf83ZVtPVfi+BN9VjUPOUm9tbUoS8RU+dEx5sEJbf1cqmZ61afaQSIs/+/m4lbX1/BvERF95vjrxOMf1 jyotisensharma@Jyotis-MBP

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDoOXbrVXXWzdO0sjiDJYvPEPEAYJHS4eYS+iSTAagYlTwqXjuRYZ5PJn2LlJvGqkd+Sxbwn4GDbeGjMTzvOuTUYb7t795S0P2Y+pzKc9a03hGxC4tU8meGPLOWnJB55cMHREXT4t5qvnqCSoY0MAsY37sIRKCmK5WSXcecfRBkAalAr7LqjzlK/ujo+F09Cc+mB1VILyfszkJ2CHaf9Hznwg08MK/kZakXF3lXUC7LuVCauEnEemU6MXM5dsA25CavyM4qGYfH4d60GVlMwWWjDs4uylFLDvFxyMcfMQjaeJ+oc5GqxV2aPuDU17xrUpN6ldJXwCGKypeKGXZ root@node1.example.com

Now you can perform ssh from node1 to node2 without providing a password

[root@node1 ~]# ssh root@node2.example.com
Last login: Thu Jan  4 11:12:06 2018 from 192.xx.xx.102

[root@node2 ~]#

.


Copyright © 2010-2012 Middleware Magic. All rights reserved. |