当前位置:网站首页>Remote access and control - SSH Remote Management and TCP wrappers access control
Remote access and control - SSH Remote Management and TCP wrappers access control
2022-06-22 22:40:00 【Be the best Messi】
One 、SSH Remote management
1、 Definition
SSH(Secure Shell ) It's a secure channel protocol , It is mainly used to realize the remote login of character interface 、 Remote replication and other functions .
SSH The protocol encrypts the data transmission between the two sides , It includes the user password entered when the user logs in . therefore SSH The protocol has good security .
2、 advantage

3、 Client and server
client :Putty、Xshell、CRT
Server side :OpenSSH
- OpenSSH It's the realization of SSH Open source software agreement for the project , Applicable to all kinds of UNIX、Linux operating system .
- CentOS 7 The system is installed by default openssh Related packages , And sshd Service added as bootstrap .
4、SSH Service opening 、 Port number and configuration file
SSH Service opening
- perform “systemctl start sshd” Command to start sshd service
SSH The port number of the service - sshd The default port number used by the service is 22
SSH The configuration file for the service - sshd_config The configuration file is for the server
- ssh_config It's a profile for the client
Two 、 To configure OpenSSH Server side
1、 Configuration file common settings options




2、AllowUsers and DenyUsers
AllowUsers and DenyUsers Can't be used at the same time . There will be conflict



3、 ... and 、 Use SSH Client program
1、SSH Remote login
ssh [ Options ] [email protected]
When a user logs in for the first time SSH Server time , Must accept the server from ECDSA Secret key ( Enter... At the prompt "yes") Before you can continue to verify . The received secret key information will be saved to ~/.ssh/known_hosts In file , After successful password verification , You can log in to the command environment of the target server .
Options explain
-1 Compulsory use ssh Protocol version 1
-2 Compulsory use ssh Protocol version 2
-4 Compulsory use IPv4 Address
-6 Compulsory use IPv6 Address
-A Turn on the authentication agent connection forwarding function
-a Turn off the authentication agent connection forwarding function
-b Use the address specified by this machine as the source of the peer-to-peer connection IP Address
-C Request to compress all data
-F Appoint ssh The configuration file for the command , The default configuration file is “/etc/ssh/ssh_config”
-f The background to perform ssh Instructions
-g Allow the remote host to connect to the forwarding port of this machine
-i Specify the identity file ( Private key file )
-l Specify the login user name to connect to the remote server
-N Do not execute remote instructions
-o Specify configuration options
-p Specify the port on the remote server
-q silent mode , All warning and diagnostic messages are disabled
-X Turn on X11 Forward capability
-x close X11 Forward capability
-y Turn on trust X11 Forward capability
2、SCP Remote Replication
①、 Downlink replication
scp -r [email protected]:/etc/ /root/
Copy 192.168.0.5 The host /etc All contents in the directory are transferred to this computer /root Directory
②、 Uplink replication
scp -r /etc/ [email protected]:/root
Copy the of this machine /etc Contents in directory to 192.168.0.6 The host /root Under the table of contents
3、sftp Security FTP
Because of the use of encryption / Decryption technology , So the transmission efficiency is higher than the ordinary FTP Be low , But it's more secure .
sftp [email protected]
[email protected]'s password:
Connected to 192.168.226.20.
sftp> ls
sftp> get file name # Download the file
sftp> put file name # Upload files
sftp> exit # sign out


Four 、sshd The service supports two authentication methods
1、 Password authentication
Login name of the local system user in the server 、 Password verification . Simple and convenient , But it could be brutally cracked
2、 Key pair verification
Matching key information is required to pass the verification . Usually create a pair of key files in the client first ( Public key 、 Private key ), Then put the public key file in the specified location in the server . When logging in remotely , The system will use the public key 、 The private key is encrypted / Decryption Association verification . Can enhance security , No login and interaction .
When password verification 、 When key pair verification is enabled , The server will take precedence over key pair Authentication . The verification mode can be set according to the actual situation .
vim /etc/ssh/sshd_config
PasswordAuthentication yes # Enable password authentication
PubkeyAuthentication yes # Enable key pair validation
AuthorizedKeysFile .ssh/authorized_keys # Specify the public key library file

①、 Create a secret key pair on the client
adopt ssh-keygen Tool to create a key pair file for the current user . The available encryption algorithms are RSA、ECDSA or DSA etc. (ssh-keygen Ordered “-t” Option to specify the type of algorithm ).
useradd admin
echo "123456" | passwd --stdin admin
su - admin
ssh-keygen -t rsa
Generating public/private ecdsa key pair.
Enter file in which to save the key (/home/ljm/.ssh/id_rsa): # Specify the private key location , Press enter to use the default location
Created directory '/home/admin/.ssh'. # Generated private key 、 The public key file is stored in the hidden directory in the host directory by default .ssh/ Next
Enter passphrase (empty for no passphrase): # Set the password for the private key
Enter same passphrase again: # Confirm input
ls -l .ssh/id_admin* #id_ecdsa It's a private key file , Permissions default to 600;id_ecdsa.pub It's a public key file , To provide to SSH The server

②、 Upload the public key file to the server
scp ~/.ssh/id_r
sa.pub [email protected]:/opt
or
This method can be used directly on the server /home/admin/.ssh/ The public key text is imported into the directory
cd ~/.ssh/
ssh-copy-id -i id_rsa.pub [email protected]

③、 Import the public key text into the server ( The second one )
mkdir .ssh
ls -A
cat /id_rsa.pub >> .ssh/authorized_keys
cat authorized_keys

④、 Use secret key pair authentication on the client
ssh [email protected]
@192.168.226.20's password: # Enter the password for the private key

⑤、 Set up on the client ssh Agent function , Realize interactive login free
ssh-agent bash
ssh-add
Enter passphrass for /root/.ssh/id_rsa: # Enter the password for the private key
[email protected]

5、 ... and 、TCP Wrappers Access control

TCP Wrappers take TCP Service program “ The parcel ” get up , Monitor for TCP The port of the server , Added a security detection process , External connection requests must first pass this layer of security detection , Access to the real service program is only possible with permission .
majority Linux Distribution version ,TCP Wrappers It's a default feature .
rpm -q tcp_wrappers
Query whether to install
1、 There are two ways to implement the protection mechanism
Use it directly tcpd Programs protect other services , Need to run tcpd Program .
Called by other network service programs libwrap.so.* Link library , No need to run tcpd Program . This method is more widely used , And more efficient .
①、 Viewing program libwrap.so.* Link library ——ldd command
ldd [ Parameters ] [ file ]
Description of common parameters -v Detail mode , Print all relevant information
-u Print unused direct dependencies
-d Perform relocation and report any missing objects
-r Perform relocation of data objects and functions , And report any missing objects and functions
– -help Display help information
The file needs to be written with an absolute path
When we don't know the absolute path of the file , have access to which Command query
You can also use two commands together :ldd $(which sshd)
2、TCP Wrappers Access policy for
TCP Wrappers The protection objects of the mechanism are various network service programs , Access control for the client address of the access service .
The corresponding two policy files are /etc/hosts.allow and /etc/hosts.deny, It is used to set the allow and reject policies respectively .

3、TCP Wrappers The basic principles of the mechanism
First check /etc/hosts.allow file , If you find a matching strategy , Access to ;
Otherwise continue to check /etc/hosts.deny file , If you find a matching strategy , Access denied ;
If you check the two files above and find no matching policy , Access to .
Allow all , Refuse individual
Just in /etc/hosts.deny Add the corresponding rejection policy to the file
Allow individual , Reject all
In addition to the /etc/hosts.allow In addition to the allowed policy , Still need to be in /etc/hosts.deny Set in file “ALL:ALL” The rejection strategy of .
4、 Example
Just hope from IP The address is 12.0.0.1 The host of or located in 192.168.80.0/24 Host access of network segment sshd service , Other addresses are rejected .
vi /etc/hosts.allow
sshd:12.0.0.1,192.168.80.*
vi /etc/hosts.deny
sshd:ALL
Catalog
4、SSH Service opening 、 Port number and configuration file
Two 、 To configure OpenSSH Server side
1、 Configuration file common settings options
3、 ... and 、 Use SSH Client program
Four 、sshd The service supports two authentication methods
1、 There are two ways to implement the protection mechanism
2、TCP Wrappers Access policy for
3、TCP Wrappers The basic principles of the mechanism
边栏推荐
- MySQL constraints
- Uninstall mavros
- redis 报错解决与常用配置
- Several ways of redis persistence -- deeply parsing RDB
- Dragon City in Europe | National Geographic the most romantic and safe destination in the world
- A case of misuse of append
- SPA项目开发之动态树+数据表格+分页
- 欧洲的龙之城|国家地理全球最浪漫最安全的目的地
- Mysql8 installation and environment configuration
- What are the methods of software stress testing and how to select a software stress testing organization?
猜你喜欢

General trend wisdom to create inclined model and cut monomer

LinkedList source code analysis

Grafana report display of sentinel based high availability current limiting system

SPA项目开发之首页导航+左侧菜单

There are 15 necessary knowledge points for the second level cost engineer before the exam! I wish you success!

【几何法视觉】4.2 分段线性变换

Pycharm configuring remote connection server development environment

Plan and change of continuous repair

Technology cloud report: East to West computing is not only about "computing", but also needs "new storage"

Home page navigation + left menu of spa project development
随机推荐
Rapideye, spot satellite remote sensing image data
立體渲染
Mysql database DML operation exercise
5分钟快速上线Web应用和API(Vercel)
【路径规划】第一周: 路径规划 开源代码汇总(ROS) 版本
Wechat applet batch submission for review
【论文解读】关于基于视觉无人机自主降落平台的论文梳理
Implementation of depth traversal adjacency table in Figure 6-7
Registration of spa project development
NiO copy file call getchannel method transferfrom()
Do not know how to choose the development of digital currency wallet?
7-9 super Mary
R language data Table data import practice: data Rename the name of the table data column (rename)
How to quickly build an enterprise knowledge base at low cost?
How to use the data dictionary function in the low code platform of the Internet of things?
volume rendering
Dynamic tree + data table + pagination of spa project development
【ROS】ROSmsg cakin_ Make compilation error
Home page navigation + left menu of spa project development
322.零钱兑换