Install ssh
yum install openssh
View port
netstat -ntpl
netstat -ntpl | grep :22
Startup and shutdown
service sshd restart/start/top redhat6 version command
systemctl restart/start/stop sshd redhat7 version command
boot:
systemctl enable/disable sshd
ssh configuration file
/etc/ssh/sshd_config
PermitRootLogin yes/no Whether to prohibit root remote login
Turn on the settings of PermitRootLogin, RSAAuthentication, and PubkeyAuthentication.
Note: If the current OpenSSH is above 7.3+, RSAAuthentication needs to be commented out as shown in the figure.
Because this configuration only supports SSH Protocol version 1, Openssh 7.3+ and above use SSH Protocol version 2.
SSH passwordless connection mode:
Client configuration commands:
ssh-kengen generates public key and secret key
或 ssh-keygen -t rsa
After the generation is successful, two files id_rsa id_rsa.pub will be generated in the /root/.ssh/ directory
ssh-copy-id /root/.ssh/id_rsa.pub 192.168.1.1 (Server IP: 192.168.3.1, cp the public key to the /root/.ssh/ directory of the server)
ssh [email protected] test connection requires password verification
The authorized_keys file stores the public key of the client.
Configure login strategy for ssh
Settings allow:
# vi /etc/hosts.allow
sshd:10.0.5.6 (10.0.0.0/24,*.ming.com)
:wq
Set rejection:
# vi /etc/hosts.deny
sshd:10.0.0.3 (10.0.0.0/24,*.ming.com)
:wq