RHCE(4)
使用client的xiaoming用户基于秘钥认证方式通过端口2000使用ssh登录server端的xiaoming用户和xiaohei用户,server端的其他用户都不可被远程登录。
- 查看是否装包:
服务端:openssh-server
客户端:openssh-clients
- 客户端:
(1)添加用户
[[email protected] ~]# useradd xiaoming
[[email protected] ~]# passwd xiaoming
Changing password for user xiaoming.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
(2)客户端生成一对秘钥
[[email protected] ~]$ cd /home/xiaoming/.ssh
[[email protected] .ssh]$ ll
total 8
-rw-------. 1 xiaoming xiaoming 2655 Jun 15 03:35 id_rsa
-rw-r--r--. 1 xiaoming xiaoming 568 Jun 15 03:35 id_rsa.pub
(3) 客户端将公钥发送至服务端指定的用户下
[[email protected] .ssh]$ ssh-copy-id [email protected]
[[email protected] .ssh]$ ssh-copy-id [email protected]
服务端:
添加用户:
修改配置文件:
[[email protected] ~]# vim /etc/ssh/sshd_config
#Port 22
Port 2000
PasswordAuthentication no
AllowUsers xiaoming xiaohei
重启服务:
[[email protected] ~]# systemctl restart sshd
客户端测试: