RHCE第二次作业

实验:使用client的xiaoming用户基于秘钥认证方式使用ssh登录server端的xiaoming用户和xiaohei用户

一、添加xiaoming和xiaohei两个普通用户

[root@localhost ~]# useradd xiaoming
[root@localhost ~]# useradd xiaohei

二、给xiaoming用户和xiaohei用户设置密码

[root@localhost ~]# 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.
[root@localhost ~]# passwd xiaohei
Changing password for user xiaohei.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.

三、在xiaoming用户端创建密钥对

[xiaoming@localhost ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xiaoming/.ssh/id_rsa):
Created directory '/home/xiaoming/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/xiaoming/.ssh/id_rsa.
Your public key has been saved in /home/xiaoming/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:BecU8MUqdq0KmETpPNGLUEx8WaYWqGoT6wFUooAKD9M xiaoming@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|oo.*o+.o=.+o.    |
|B.E B ++ * ..    |
|=+ * +o.  +o     |
|o.o *.. o.o .    |
|..o. + .So .     |
|.=  o .   .      |
|o o    . .       |
| .      .        |
|                 |
+----[SHA256]-----+

四、把创建的公钥文件复制到xiaoming用户和xiaohei用户的服务端目录下

[xiaoming@localhost ~]$ ssh-copy-id xiaoming@192.168.190.133
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/xiaoming/.ssh/id_rsa.pub"
The authenticity of host '192.168.190.133 (192.168.190.133)' can't be established.
ECDSA key fingerprint is SHA256:BZo7UCK5RNPgKV+RMQA3ftl+Opx5Y5uU14fVznlw0Ts.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
xiaoming@192.168.190.133's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'xiaoming@192.168.190.133'"
and check to make sure that only the key(s) you wanted were added.

[xiaoming@localhost ~]$ ssh-copy-id xiaohei@192.168.190.133
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/xiaoming/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
xiaohei@192.168.190.133's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'xiaohei@192.168.190.133'"
and check to make sure that only the key(s) you wanted were added.

五、登录验证

[xiaoming@localhost ~]$ ssh xiaohei@192.168.190.133
4.18.0-348.el8.x86_64
Red Hat Enterprise Linux release 8.5 (Ootpa)
localhost.localdomain
/bin/bash
Activate the web console with: systemctl enable --now cockpit.socket

This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register

[xiaohei@localhost ~]$

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SUPER COW

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值