Hello all, hope that you are well. Lets see, what is in todays post. To I’m going to show you how to configure SSH. SSH generally stands for Secure Shell.
SSH configure in Linux (CentOS/Red Hat)
It is a application which is generally used in the work of remote admintration of any server, router, firewalld etc. Generally it uses a port no. by default it uses the 22 port no. You can change the port no according to your network design. As you know, you need a installed package for this service. Generally for SERVER a package named openssh-server need to be installed. And for client it needs a client package named openssh-client. The Daemon is sshd. Generally the configure file found the “/etc/ssh/sshd_config”.
So we’ve learn something, now lets goto the step by step configuration:
Lets change the Host Name:
[root@localhost ~]# echo ssh-serverX.example.com > /etc/hostname[root@localhost ~]# logout
[root@ssh-serverX ~]#
Step 01: Install the RPM Query
[root@ssh-serverX ~]# rpm -qa | grep openssh-serveropenssh-server-6.4p1-8.el7.x86_64 [root@ssh-serverX ~]# yum install openssh* -y [if not found] [root@ssh-serverX ~]# systemctl restart sshd.service
[root@ssh-serverX ~]# systemctl enable sshd.service
[root@ssh-serverX ~]# systemctl status sshd.service [root@ssh-serverX ~]# ifconfig
(Optional): Temporary IP Configure:
———————————-
ifconfig eth0 172.25.11.200+X netmask 255.255.255.0
Now need to install the SSH Client:
Generally in the case of Linux, the client is installed previously.
But in the windows, you need to install manually. Different types of client is for windows. In this we’ve chosen putty. Putty is a popular client in windows platform.
Now lets test:
Move to Desktop
> ping 192.168.2.2+X (ssh server)
SSH Login with Root User
[root@desktopX ~]# ssh root@192.168.2.2+XAre you sure you want to continue connecting (yes/no)? yes
root@192.168.2.2+X’s password: ****** (remote PC)
[root@ssh-serverX ~]# useradd user1
[root@ssh-serverX ~]# passwd user1
: 123
: 123 [root@ssh-serverX ~]# exit
Linux with user1:
[root@desktopX ~]# ssh root@192.168.2.2+X hostname [root@desktopX ~]# ssh user1@192.168.2.2+X [user1@serverX~]$ su –: ******** [root@ssh-serverX ~]# who
[root@ssh-serverX ~]# exit
[root@desktopX ~]#
Now we’ll use the Secure Copy using “scp” command from server:
[root@desktopX ~]# scp root@172.25.11.200+X:/etc/passwd /root/DesktopSecure Copy (scp) to serverX:
[root@desktopX ~]# scp /etc/passwd root@172.25.11.200+X:/rootPassword Less ssh login:
[root@desktopX ~]# cd[root@desktopX ~]# ls
[root@desktopX ~]# ls -la
[root@desktopX ~]# cd .ssh
[root@desktopX .ssh]# ls
known_host (list of known hosts) id_rsa.pub id_rsa [root@desktopX .ssh]# rm -rf * [root@desktopX .ssh]# ls
[root@desktopX .ssh]# ssh user1@172.25.11.200+X
Are you sure you want to continue connecting (yes/no)? yes
press Ctlrl+C
[root@desktopX .ssh]# lsknown_host (created) [root@desktopX .ssh]# ssh-keygen ; (Enter 3 Times)
id_rsa.pub id_rsa [root@desktopX .ssh]# cat id_rsa
[root@desktopX .ssh]# cat id_rsa.pub [root@desktopX .ssh]# ssh-copy-id user1@172.25.11.200+X (serverX)
[root@desktopX .ssh]# ssh user1@172.25.11.200+X [user1@ssh-serverX ~]$ cd .ssh
[user1@ssh-serverX .ssh]$ ls
authorized_keys [user1@serverX .ssh]$ cat authorized_keys ; same as public key of desktopX
Now we’ll move to serverX (Virtually)
As you know, and we previously said that our default port is portt no 22. According to our need we can change default port:
[root@deX ~]# netstat -ntlp | grep ssh [root@serverX ~]# vim /etc/ssh/sshd_config:set nu
17 #Port 22 ; old
17 Port 2015 ; remove ‘#’
[root@serverX ~]# setenforce 0
[root@serverX ~]# systemctl stop firewalld
[root@serverX ~]# systemctl disable firewalld
Now we’ll verify curren SSH port:
[root@serverX ~]# netstat -ntlp | grep sshNow lets move to desktopX (Physically)
Now we’ll try SSH Server Login with Specif Port:
[root@desktopX ~]# ssh user1@192.168.2.2+X (default port) – Refused [root@desktopX ~]# ssh -p 2015 user1@172.25.11.200+X ; if user1 user [user1@serverX ~]$ exitNow if you want, and if you are a server admin, you can disable root login.
[root@serverX ~]# vim /etc/ssh/sshd_config:set nu
48 #PermitRootLogin yes ;old
48 PermitRootLogin no ;new
Now test the system:
[root@desktopX ~]# ssh -p 2015 root@192.168.2.2+X [root@desktopX ~]# ssh -p 2015 user1@192.168.2.2+XHope that it is working. Also you’ve enjoyed.
Waiting for your comments.
🙂
Leave a Reply