[root@server100 ~]# hostnamectl hostname server.example.com
[root@server100 ~]# useradd timinglee
[root@server100 ~]# echo timinglee | passwd --stdin timinglee
[root@client200 ~]# hostnamectl hostname client.example.com
2、[root@server100 ~]# vim /etc/ssh/ssh_config
Port 2222
[root@server100 ~]# systemctl restart sshd
[root@server100 ~]# netstat -antlupe | grep sshd
tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN 0 23872 9
[root@server100 ~]# vim /etc/ssh/sshd_config
PermitRootLogin yes
AllowUsers timinglee root
PasswordAuthentication yes
[root@server100 ~]# systemctl restart sshd
[root@client200 ~]# ssh-keygen -f /root/.ssh/id_rsa -P ""
[root@client200 ~]# cd /root/.ssh
[root@client200 .ssh]# ls
id_rsa id_rsa.pub known_hosts known_hosts.old
[root@client200 .ssh]# ssh-copy-id -i id_rsa.pub root@172.25.254.100
测试:
[root@client200 .ssh]# ssh -l root 172.25.254.100 -p 2222
Activate the web console with: systemctl enable --now cockpit.socket
Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Sat Apr 20 22:33:06 2024 from 172.25.254.200
[root@client200 ~]#
[root@client200 ~]# ssh -l timinglee 172.25.254.100 -p 2222
timinglee@172.25.254.100's password:
Permission denied, please try again.
timinglee@172.25.254.100's password:
Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last failed login: Sat Apr 20 22:52:10 CST 2024 from 172.25.254.200 on ssh:notty
There were 4 failed login attempts since the last successful login.