Moment For Technology

Network services Chapter 3 OPENSSH Remote Control and TCP Wrappers Security Protection

Posted on Oct. 3, 2022, 4:44 a.m. by Anita Nelson
Category: The back-end Tag: operations The back-end

Introduction to SSH

As a secure channel protocol, SSH is used to implement remote login and remote replication functions on character interface. The SSH protocol encrypts the data of both parties, including the password entered during login. Compared with TELNET(remote login), RSH (remote command execution), and RCP (remote replication), SSH provides better security.

SSH listens on port 22 by default

2. OpenSSH configuration

BS and CS architecture

BS browser/server side

CS client/server

1. Listen options

[[email protected] ~]# vim /etc/ssh/sshd_config

Port 22 Listens on Port 22

#ListenAddress default ListenAddress

UseDNS no Disables DNS reverse lookup to speed up connections

2. The user logs in to the air control

By default, the SSH service allows user root to log in to the system. This is insecure. In the production environment, you need to disable user root to log in to the system as a common user.

[[email protected] ~]# vim /etc/ssh/sshd_config

#LoginGraceTime 2m #Login authentication time

#PermitRootLogin yes # Disable user root from logging in

MaxAuthTries 6 Specifies the maximum number of retries

#PermitEmptyPasswords no # Disallow users with empty passwords

OPENSSH service access control

AllowUsers Allows only users to log in

DenyUsers disables only users from logging in

Pay attention to

1)AllowUsers and DenyUsers should not be used together

2) If the server is on the network, the IP address contained in the control shall be the public IP address of the company

AllowUsers [email protected] # only AllowUsers like linyu to log in

A server typically has four network adapters, EM1-4

3. Login authentication mode

1) SSH authentication mode

Password authentication

Key pair authentication

Authorizedkeysfile. SSH /authorized_keys # Specifies the location where the public key is stored

Three, SSH client program

1. Use the SSH command

SSH [email protected] touch/TMP/a.t xt

You can not only log in remotely but also execute commands remotely

2. SCP remote replication

SCP / etc/hosts/etc/hosts

SCP -r directory plus r

3. Run SFTP

Format: SFTP IP address

Get the download

Put the upload

LCD Switching Directory

4, Windows



4. Build SSH system for key pair authentication

1. The verification process consists of four steps

2. Create a key pair on the client (the created key pair is stored in /home/.ssh of the peer directory).

On the Linux client, run the ssh-keygen command tool to create a key pair file for the current login user. The available encryption algorithm is as follows:

ECDSA, RSA, and DSA can be specified using the -t option. The default algorithm is RSA

3. Upload the public key to the server

4. Import public key text on the server

Non-interactively generates a key pair

[[email protected] ~]# ssh-keygen -t ecdsa -P "" -f .ssh/id_ecdsa

Windows generates a key pair

Click the Xshell tools TAB -- New User Key Generation Wizard

Five, the TCP Wrappers

In Linux, many network services provide access control for clients

1. Principle of TCP Wrappers protection

2. Implementation of protection mechanism

Method 1. Package other service programs through TCPD main program

Option 2. Other services call the connection library

3. Protection conditions

1) The service must be TCP

2) The library must contain (shared link library), most services through this service

LDD command description

LDD is not a program itself, but a shell script: LDD lists the dynamic link libraries (SO) that a program needs.

`[[email protected] ~]# ldd /usr/sbin/sshd | grep libwrap = /lib64/ (0x00007f3a9e0f7000)

[[email protected] ~]# ldd /usr/sbin/vsftpd | grep libwrap = /lib64/ (0x00007f37a748a000)`

TCPWRAP principle

/ etc/hosts. Allow # allows

/ etc/hosts. # refused to deny

Access control Policy

The /etc/host.allow file has a higher priority. If the same IP address exists in hosts.allow, it also exists in hosts.deny

The IP address will be accepted.

5. Configuration format

1) format

Service list: client address list

Note cannot be written to the network segment

2) Configuration examples

Only hosts whose IP addresses range from to are allowed to access the SSHD service.

[[email protected] ~]# vim /etc/hosts.allow


[[email protected] ~]# vim /etc/hosts.deny


Example for configuring public network servers:

About (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.