7月17日练习

普通用户免密登录管理员root、普通用户免密登录普通用户、创建用户设置密码,创建组,把普通用户加入组中,给组写权限

[root@13 ~]# useradd wangwu
[root@13 ~]# useradd zhaoliu
[root@13 ~]# useradd aaa
[root@13 ~]# useradd bbb
[root@13 ~]# useradd ccc
[root@13 ~]# useradd ddd
[root@13 ~]# passwd wangwu
更改用户 wangwu 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@13 ~]# passwd zhaoliu
更改用户 zhaoliu 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@13 ~]# passwd aaa
更改用户 aaa 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@13 ~]# passwd bbb
更改用户 bbb 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@13 ~]# passwd ccc
更改用户 ccc 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@13 ~]# ddd
bash: ddd: 未找到命令
[root@13 ~]# passwd ddd
更改用户 ddd 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@13 ~]# 

[root@13 ~]# mkdir /code

[root@13 ~]# groupadd code

[root@13 ~]# usermod -g code wangwu
[root@13 ~]# usermod -g code zhaoliu
[root@13 ~]# usermod -g code aaa
[root@13 ~]# usermod -g code bbb
[root@13 ~]# usermod -g code ccc
[root@13 ~]# usermod -g code ddd

[root@13 ~]# chgrp -R code /code/

[root@13 ~]# chmod -R g+w /code/

[root@13 ~]# vim /etc/ssh/sshd_config
17  Port 9999
[root@13 ~]# systemctl restart sshd     
[root@13 ~]# systemctl stop firewalld
[root@13 ~]# setenforce 0
[root@13 ~]# 

用户yulan 免密登录lisi: 

[yulan@14 ~]# ssh-copy-id -p9999 lisi@192.168.2.13
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.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
lisi@192.168.2.13's password: 

Number of key(s) added: 1

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

[yulan@14 ~]# ssh -llisi -p9999 192.168.2.13
Last login: Wed Jul 17 16:50:14 2024
[lisi@13 ~]$ exit
登出
Connection to 192.168.2.13 closed.
[yulan@14 ~]# 
用户wangwu 免密登录:

[root@13 ~]# su wangwu
Attempting to create directory /home/wangwu/perl5
[wangwu@13 root]$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wangwu/.ssh/id_rsa): 
Created directory '/home/wangwu/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/wangwu/.ssh/id_rsa.
Your public key has been saved in /home/wangwu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:CNsMQTX6SZJGXRDtcKpWcZzY5nV7tlUXBMpNdOGgf8k wangwu@13
The key's randomart image is:
+---[RSA 2048]----+
|   .+o=O..  .=o=o|
|   . +=.O o * + o|
|    B .X . = o .o|
|   . Xooo   o + o|
|    .o* S    + E |
|    o         o  |
|   .             |
|                 |
|                 |
+----[SHA256]-----+
[wangwu@13 root]$ cd
[wangwu@13 ~]$ ls ./.ssh/
id_rsa  id_rsa.pub
[wangwu@13 ~]$ ssh-copy-id root@192.168.2.14
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/wangwu/.ssh/id_rsa.pub"
The authenticity of host '192.168.2.14 (192.168.2.14)' can't be established.
ECDSA key fingerprint is SHA256:DFQPeJuLPiA/K0OYrrZoRt1BhKyxWLVaHvJH0afkFjc.
ECDSA key fingerprint is MD5:98:77:aa:0a:39:d6:ef:64:31:f9:c4:59:ab:13:59:12.
Are you sure you want to continue connecting (yes/no)? 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
root@192.168.2.14's password: 

Number of key(s) added: 1

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

[wangwu@13 ~]$ ssh -lroot 192.168.2.14
Last login: Wed Jul 17 16:52:09 2024 from 192.168.2.13
[root@14 ~]# exit
登出
Connection to 192.168.2.14 closed.
[wangwu@13 ~]$ exit
exit
[root@13 ~]# 
用户zhaoliu 免密登录:

[root@13 ~]# su zhaoliu
Attempting to create directory /home/zhaoliu/perl5
[zhaoliu@13 root]$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/zhaoliu/.ssh/id_rsa): 
Created directory '/home/zhaoliu/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/zhaoliu/.ssh/id_rsa.
Your public key has been saved in /home/zhaoliu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ihdb4c8oxx5v5Y/X+CPGfEhdtLnXGamwWcP/RK/N5sI zhaoliu@13
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                .|
|        .   .  .+|
|       . . . + =o|
|      . S   = =.B|
|     . * + o.o ==|
|    . = = oo+..Bo|
|     . + o. .BEo*|
|        ... oo+=+|
+----[SHA256]-----+
[zhaoliu@13 root]$ cd
[zhaoliu@13 ~]$ ls ./.ssh/
id_rsa  id_rsa.pub
[zhaoliu@13 ~]$ ssh-copy-id root@192.168.2.14
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/zhaoliu/.ssh/id_rsa.pub"
The authenticity of host '192.168.2.14 (192.168.2.14)' can't be established.
ECDSA key fingerprint is SHA256:DFQPeJuLPiA/K0OYrrZoRt1BhKyxWLVaHvJH0afkFjc.
ECDSA key fingerprint is MD5:98:77:aa:0a:39:d6:ef:64:31:f9:c4:59:ab:13:59:12.
Are you sure you want to continue connecting (yes/no)? 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
root@192.168.2.14's password: 

Number of key(s) added: 1

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

[zhaoliu@13 ~]$ ssh -lroot 192.168.2.14
Last login: Wed Jul 17 17:29:44 2024 from 192.168.2.13
[root@14 ~]# exit
登出
Connection to 192.168.2.14 closed.
[zhaoliu@13 ~]$ exit
exit
[root@13 ~]# 
用户aaa 免密登录:

[root@13 ~]# su aaa
Attempting to create directory /home/aaa/perl5
[aaa@13 root]$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/aaa/.ssh/id_rsa): 
Created directory '/home/aaa/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/aaa/.ssh/id_rsa.
Your public key has been saved in /home/aaa/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:422v4N2RtmLHSBg95RaTnH3LyVkypyoNcSslt2+5uE4 aaa@13
The key's randomart image is:
+---[RSA 2048]----+
|           . +   |
|          o @ + +|
|         . O =o*=|
|        . = = .* |
|        So * o . |
|       ..oo o.+  |
|        o.o+Eo . |
|       . ++=+o.  |
|        ..o=*.   |
+----[SHA256]-----+
[aaa@13 root]$ cd
[aaa@13 ~]$ ls ./.ssh/
id_rsa  id_rsa.pub
[aaa@13 ~]$ ssh-copy-id root@192.168.2.14
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/aaa/.ssh/id_rsa.pub"
The authenticity of host '192.168.2.14 (192.168.2.14)' can't be established.
ECDSA key fingerprint is SHA256:DFQPeJuLPiA/K0OYrrZoRt1BhKyxWLVaHvJH0afkFjc.
ECDSA key fingerprint is MD5:98:77:aa:0a:39:d6:ef:64:31:f9:c4:59:ab:13:59:12.
Are you sure you want to continue connecting (yes/no)? 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
root@192.168.2.14's password: 

Number of key(s) added: 1

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

[aaa@13 ~]$ ssh -lroot 192.168.2.14
Last login: Wed Jul 17 17:34:23 2024 from 192.168.2.13
[root@14 ~]# exit
登出
Connection to 192.168.2.14 closed.
[aaa@13 ~]$ exit
exit
[root@13 ~]# 

用户bbb 免密登录ccc:

[root@13 ~]# su bbb
Attempting to create directory /home/bbb/perl5
[bbb@13 root]$ ssh -lccc 192.168.2.13
ssh: connect to host 192.168.2.13 port 22: Connection refused
[bbb@13 root]$ su ccc
密码:
Attempting to create directory /home/ccc/perl5
[ccc@13 root]$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ccc/.ssh/id_rsa): 
Created directory '/home/ccc/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/ccc/.ssh/id_rsa.
Your public key has been saved in /home/ccc/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:8WJ4I2QPt5ngTvKq0ZbT7/HbmFlC/Y92KOs8Nqgg0u0 ccc@13
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|      = o        |
|     + * * .     |
|    . = S o .    |
|   o O + +   .   |
|  o B * . ... .. |
|   + = o o.O= oo.|
|  ... E.+.*+=*...|
+----[SHA256]-----+
[ccc@13 root]$ cd
[ccc@13 ~]$ ls ./.ssh/
id_rsa  id_rsa.pub


[ccc@13 ~]$ ssh-copy-id -p9999 ccc@192.168.2.13
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ccc/.ssh/id_rsa.pub"
The authenticity of host '[192.168.2.13]:9999 ([192.168.2.13]:9999)' can't be established.
ECDSA key fingerprint is SHA256:DFQPeJuLPiA/K0OYrrZoRt1BhKyxWLVaHvJH0afkFjc.
ECDSA key fingerprint is MD5:98:77:aa:0a:39:d6:ef:64:31:f9:c4:59:ab:13:59:12.
Are you sure you want to continue connecting (yes/no)? ys
Please type 'yes' or 'no': 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
ccc@192.168.2.13's password: 

Number of key(s) added: 1

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

[ccc@13 ~]$ ssh -lbbb -p9999 192.168.2.13
bbb@192.168.2.13's password: 
Last login: Wed Jul 17 17:48:21 2024
[bbb@13 ~]$ 
[bbb@13 ~]$ exit
登出
Connection to 192.168.2.13 closed.
[ccc@13 ~]$ exit
exit
 

用户ddd 免密登录root:

[root@13 ~]# su ddd
Attempting to create directory /home/ddd/perl5
[ddd@13 root]$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ddd/.ssh/id_rsa): 
Created directory '/home/ddd/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/ddd/.ssh/id_rsa.
Your public key has been saved in /home/ddd/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:+euMKXDUWV9QdvOaL8nDvPRnx9aCshTIzrgAfj8i6PE ddd@13
The key's randomart image is:
+---[RSA 2048]----+
|            .oo..|
|          .  ...o|
|       . o . .  .|
|      ..oo  .  o |
|  .  .  S .   o  |
| . .. .+ . . + o |
| o. oo. o o  .O.o|
|. +..oo. =.....=B|
|.. E .ooo.=o  .++|
+----[SHA256]-----+
[ddd@13 root]$ cd
[ddd@13 ~]$ ls ./.ssh/
id_rsa  id_rsa.pub
[ddd@13 ~]$ ssh-copy-id root@192.168.2.14
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ddd/.ssh/id_rsa.pub"
The authenticity of host '192.168.2.14 (192.168.2.14)' can't be established.
ECDSA key fingerprint is SHA256:DFQPeJuLPiA/K0OYrrZoRt1BhKyxWLVaHvJH0afkFjc.
ECDSA key fingerprint is MD5:98:77:aa:0a:39:d6:ef:64:31:f9:c4:59:ab:13:59:12.
Are you sure you want to continue connecting (yes/no)? 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
root@192.168.2.14's password: 

Number of key(s) added: 1

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

[ddd@13 ~]$ ssh -lroot 192.168.2.14
Last login: Wed Jul 17 17:48:09 2024 from 192.168.2.13
[root@14 ~]# exit
登出
Connection to 192.168.2.14 closed.
[ddd@13 ~]$ exit
exit
[root@13 ~]# 

  • 17
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值