SSH Passwordless Login Using SSH Keygen in 5 Easy Steps 22 Port

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Q:1 What is Kdump and why it is required ?

Ans: Kdump is a mechanism to capture crash dumps when the system crash or kernel panic occur. Crash dumps can be
stored either on remote file system or on local file system.By analyzing the crash dumps we can find the root cause of
system failure or kernel panic. In case if you OS vendor support then you can share the vmcore file with the vendor for
further analysis.
Q:2 How to check when was the file system scan last time ?
Ans: With help of tune2fs command we can check when was the file system scan for errors.
# tune2fs -l <Device_Name> | grep “Last checked”
Q:3 How to change Password expiry date of a account without changing its password ?
Ans: With help of chage command we can extend the password expiry date of a local account. Syntax is show below
# chage -d <date-in-yy-mm-dd> <User_Name>
Q:4 How to run fsck forcefully on a OS file system on next reboot ?
Ans: To run fsck forcefully on a particular file system on next reboot, create a empty file with name ‘forcefsck’ in the file
system . Let’s assume we want to run fsck on /home file system on next reboot.
# cd /home ; touch forcefsck ; reboot
Q:5 Which tool is used to analyze crash dump or vmcore file on CentOS 7 & RHEL 7 ?
Ans: crash is the utility or command on CentOS 7 and RHEL 7 through we can analyze crash dumps.
Q:6 How to install all the patches except kernel on CentOS and RHEL ?
Ans: Using the ‘–exclude=kernel*’ parameter in the yum command we can install all patches except kernel. Example is
shown below
# yum update –exclude=kernel*
Add the below entry in the file ‘/etc/yum.conf’ to prevent updating kernel permanently.
exclude=kernel*
Q:7 How to check whether you are working on Physical or Virtual Server ?
Ans:Use below dmidecode command to check whether your are working on Physical or virtual server.
# dmidecode -t system | grep “Product Name”
Product Name: VMware Virtual Platform
Q:8 What is automounter and why it is required ?
Ans: Automounter is a service in Linux like operating system which is used to mount remote file system or local file
system automatically whenever it is access. When the file system is inactive for a particular period of time then
automounter service (autofs) will automatically umount the file system. The main benefit of autofs is that the system
don’t need to mount the file system all the time, it will only mount the file system whenever it is in demand.
Q:9 How to force a user to change its password at the login ?
Ans: Use ‘chage‘ command to expire the user’s password , like “chage -d 0 <user_name>“, After this whenever user tries
to login or ssh the system, he/she will get the waring message” Your password has expired. You must change your
password now and login again”
Q:10 How to check whether the last command that you run is executed successfully or not ?
Ans : By knowing the exit status of special variable ‘$?‘ we can tell whether the last command that we run is executed
successfully or not. Example is shown below:
# ls -l /var/
# echo $?
0
# ls -l /var/wwer
# echo $?
2
Exit status zero means last command was executed successfully, exit status other than zero means unsuccessfull.
Q:11 How to check when was the particular rpm package installed ?
Ans: Let’s take an example of postfix. Use below rpm command to find when was postfix rpm installed.
[root@cloud ~]# rpm -q postfix –last
postfix-2.10.1-6.el7.x86_64 Saturday 27 February 2016 11:56:43 PM EST
[root@cloud ~]#
We can also use yum command to find above requested info.
[root@cloud ~]# yum history package postfix
Q:12 How to Login single user mode in RHEL 7 ?
Ans: Boot the system , go to GRUB2 boot loader Screen, Press ‘e’ and go to the line which starts with ‘linux16/vmlinz‘
and replace ‘ro‘ with ‘rw init=/sysroot/bin/bash‘ and Press ctrl-x to boot.
Q:13 Which Command is used to set hostname permanently on CentOS 7 & RHEL 7 ?
Ans: ‘hostnamectl‘ command is used to set or configure hostname permanently. Example is shown below
# hostnamectl set-hostname “New_HostName”
Apart from hostnamectl command ‘nmtui‘& ‘nmcli‘ are also used to set hostname in CentOS 7 and RHEL 7.
Q:14 How to enable password policies in Linux ?
Ans: Password policies can be enabled using pam(pluggable authentication module). In Centos and RHEL we have
“/etc/pam.d/system-auth” file where we define the password policies as per the requirement. In Debian based OS we
have “/etc/pam.d/common-password” file
Q:15 How to check which Kernel Modules are installed on your Linux box ?
Ans: ‘lsmod‘ command will give us the list of installed kernel modules.
Q:16 which command is used to check IO Stat in Linux ?
Ans:There are couple of command like ‘sar‘, ‘iostat‘ and ‘vmstat‘ through which we can check io stat in Linux.
Q:17 What is the use of ‘/etc/lvm/backup’ and ‘/etc/lvm/archive’ ?
Ans: When we create and update any lvm based partitions then metadata backup is stored in the file ‘/etc/lvm/backup‘
and archive meta data is kept in ‘/etc/lvm/archive‘ file. Using vgcfgrestore command we can restore the Volume group
meta data.
Q:18 How to list the routing table of your Linux box ?
Ans: Using the commands ‘route -n‘ and ‘netstat -nr‘ we can list the current routing table in Linux.
Q:19 What happen in the background when you ssh a server from your Linux machine ?
Ans: Whenever we ssh any unix server then TCP connection is formed from Client to Server on 22 port by default and
Server give the SSH protocol version it supports. If the client accepts the SSH protocol version then the connection
continues and after that server provides its host public key and client keeps that key in file ‘~/.ssh/known_hosts‘ and
then finally we get ssh prompt.
Q:20 How to change the default SSH port of your Linux Server ?
Ans: Default port (22) of SSH can be changed by updating the parameter “Port <NNN>” in the file ‘/etc/ssh/sshd_config‘.
Where NNN is port number. After making the changes either restart or reload ssh service.
Q:21 How to see timestamps in dmesg on RHEL7 ?
Ans: Using the command ‘dmesg -T‘ we can view the timestamps in dmesg.
Q:22 How to check make and Model of physical Server from Command line ?
Ans With help of dmidecode command we can find make and model of physical server, example is shown below
# dmidecode -t system
........................

Handle 0x0011, DMI type 1, 27 bytes


System Information
Manufacturer: HP
Product Name: ProLiant DL580 Gen8
Version: P79
Serial Number: CKX42926E0
UUID: 97387735-1541-238A-1B33-533850564430
Wake-up Type: Power Switch
SKU Number: 728551-B21
Family: ProLiant
...............................................
Q:23 How to check BIOS version of your server from command line ?
Ans: With help of dmidecode command we find bios version from the command line
# dmidecode -t bios
# dmidecode 2.12
SMBIOS 2.8 present.

Handle 0x0010, DMI type 0, 24 bytes


BIOS Information
Vendor: HP
Version: P79
Release Date: 04/01/2014
Address: 0xF0000
Runtime Size: 64 kB
ROM Size: 16384 kB
.............................
Q:24 How to extend the existing volume group ?
Ans: First create a pv(physical volume) on new raw disk ( /dev/sdb) using command “pvcreate /dev/sdb” and then use
vgextend command “vgextend <vloume_group_name> /dev/sdb”
Q:25 How to view WWN number of HBA card on Linux servers ?
Ans: There are two ways through which we can view WWN number of HBA Card.
First Way using the systool command like :
# systool -c fc_host -v | grep “port_name”
Second Way is using sys class files :
# cat /sys/class/fc_host/host*/port_name
0x7001639028cbeca0
0x7001639028cbefa2
0x7001639028cbf5d8
0x7001639028cbf6da

Q:1 How To check the uptime of a Linux Server ?


Ans: Using uptime command we can determine how long a linux box has been running , also uptime can be viewed by
the top & w command.
Q:2 How to check which Redhat version is installed on Server ?
Ans: Use the command cat /etc/redhat-release , output of this command will tell you the redhat version.
Q:3 How to install rpm packages in Redhat & CentOS linux ?
Ans: rpm and yum command are used to install packages in redhat linux and CentOS.
Q:4 How to check the ip address of LAN Card ?
Ans: Using ‘ifconfig’ & ‘ip address’ command we can determine the ip address of LAN Card.
Q:5 How to determine the hostname of a linux box ?
Ans: On typing the hostname command on terminal we can determine the hostname of a linux server.
Q:6 How To check the default gatway ?
Ans: Using ‘route -n’ command we can determine the default gateway in linux.
Q:7 Which Command is used to check the kernel Version ?
Ans: ‘uname -r’
Q:8 How to check the current runlevel of a linux box ?
Ans : ‘who -r’ and ‘runlevel’ , both of these command are used to find current run level.
Q:9 What is Initrd ?
Ans: Initrd stands for initial ram disk , which contains the temporary root filesystem and neccessary modules which helps
in mounting the real root filesystem in read mode only.
Q:10 What is Bootloader ?
Ans: Bootloader is a program that boots the operating system and decides from which kernel OS will boot.
Q:11 How to list hidden files from the command line ?
Ans: ‘ls -a’ <Folder_Name>
Q:12 What is soft link ?
Ans: Soft link is a method to create short cuts in linux. It is similar to windows short cut feature.
Q:13 How to create a blank file in linux from command line ?
Ans: Using the command ‘touch <file-name>’
Q:14 What is run level 2 ?
Ans: Run level 2 is the multi-user mode without networking.
Q:15 Why linux is called OpenSource ?
Ans: Because One can customize the existing code and can redistribute it.
Q:16 How to check all the installed Kernel modules ?
Ans: Using the Command ‘lsmod’ we can see the installed kernel modules.
Q:17 What is the default uid & gid of root user ?
Ans: Default uid & gid of root user is 0.
Q:18 How To change the password of user from the Command Line ?
Ans: ‘passwd <User-Name>’
Q:19 What is a Process ?
Ans: Any program in execution is called a process.
Q:20 What is name of first process in linux ?
Ans: ‘init’ is the first process in linux which is started by kernel and whose pid is 1.

SSH Passwordless Login Using SSH Keygen in 5 Easy Steps 22 port


SSH (Secure SHELL) is an open source and most trusted network protocol that is used to login into remote
servers for execution of commands and programs. It is also used to transfer files from one computer to
another computer over the network using secure copy (SCP) Protocol.
In this article we will show you how to setup password-less login on RHEL/CentOS 7.x/6.x/5.x and Fedora using
ssh keys to connect to remote Linux servers without entering password. Using Password-less login with SSH
keys will increase the trust between two Linux servers for easy file synchronization or transfer.

Setup SSH Passwordless Login


My Setup Environment
SSH Client : 192.168.0.12 ( Fedora 21 )
SSH Remote Host : 192.168.0.11 ( CentOS 7 )
If you are dealing with number of Linux remote servers, then SSH Password-less login is one of the best way to
automate tasks such as automatic backups with scripts, synchronization files using scp and remote command
execution.
In this example we will setup SSH password-less automatic login from server 192.168.0.12 as user tecmint to
192.168.0.11 with user oracle.
Step 1: Create Authentication SSH-Kegen Keys on – (192.168.0.12)
First login into server 192.168.0.12 with user tecmint and generate a pair of public keys using following
command.
[tecmint@tecmint.com ~]$ ssh-keygen -t rsa

Step 2: Create .ssh Directory on – 192.168.0.11


Use SSH from server 192.168.0.12 to connect server 192.168.0.11 using oracle as user and create .ssh
directory under it, using following command.
[tecmint@tecmint ~]$ ssh oracle@192.168.0.11 mkdir -p .ssh
Create SSH Directory Under User Home
Step 3: Upload Generated Public Keys to – 192.168.0.11
Use SSH from server 192.168.0.12 and upload new generated public key (id_rsa.pub) on server 192.168.0.11
under oracle‘s .ssh directory as a file name authorized_keys.
[tecmint@tecmint ~]$ cat .ssh/id_rsa.pub | ssh oracle@192.168.0.11 'cat >>
.ssh/authorized_keys'

Step 4: Set Permissions on – 192.168.0.11


Due to different SSH versions on servers, we need to set permissions on .ssh directory and authorized_keys
file.
[tecmint@tecmint ~]$ ssh oracle@192.168.0.11 "chmod 700 .ssh; chmod 640
.ssh/authorized_keys"

Set Permission on SSH Key


Step 5: Login from 192.168.0.12 to 192.168.0.11 Server without Password
From now onwards you can log into 192.168.0.11 as oracle user from server 192.168.0.12 as tecmint user
without password.
[tecmint@tecmint ~]$ ssh oracle@192.168.0.11
SSH Remote Passwordless Login

You might also like