RHCE---day1作业

1.配置桥接
#配置网桥
[root@localhost ~]# nmcli c add type bridge con-name br1 ifname br1 ipv4.addresses 192.168.230.222/24 ipv4.gateway 192.168.230.2 ipv4.method manual
Connection ‘br1’ (4bf065f0-a117-4dc6-bbb4-68572e3a0d20) successfully added.
#将ens224网卡连接在网桥上
#网桥的作用:转换数据包
#数据包流向=》网桥=》ens224
[root@localhost ~]# nmcli c add type bridge-slave con-name br1-port1 ifname ens224 master br1
Connection ‘br1-port1’ (752079b7-467d-4e6b-b693-59d3d9380e0c) successfully added.
[root@localhost ~]# nmcli c up br1-port1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/60)
[root@localhost ~]# nmcli c up br1
2.ssh:拒绝用户远程登录
修改配置文件:vim /etc/ssh/sshd_config
将PermitRoorLogin yes -> no
在这里插入图片描述
重启服务:systemctl restart sshd(显示被拒绝)
在这里插入图片描述
3 ssh免密登录
1.产生公钥和私钥
公钥:id_rsa.pub
私钥:id_rsa
命令:ssh-keygen -t rsa
[root@localhost ~]# cd ~/.ssh
[root@localhost .ssh]# cd ~/.ssh/
[root@localhost .ssh]# ls
known_hosts
[root@localhost .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:3sXljtxF7gdtusrkYuEMubiwhGlBuy59zrIs/MyU+XE root@localhost.localdomain
The key’s randomart image is:
±–[RSA 3072]----+
| |
| |
| . . .|
| . . . o + |
| o S. o o =|
| =o .o…o + * |
|…=+o. E.=…+ + o|
|o=*ooo+ . =+ …|
| o=O+… . .+… |
±—[SHA256]-----+
[root@localhost .ssh]# ls
id_rsa id_rsa.pub known_hosts
在这里插入图片描述

2.将公钥写入authorized_keys(=>将公钥传递给远端的服务器)
命令:ssh-copy-id 用户名
=> 将id_rsa.pub的内容写入authorized_keys文件中 (等价于:cat id_rsa.pub >> authorized_keys)
[root@localhost .ssh]# ssh-copy-id localhost
[root@localhost .ssh]# ls
authorized_keys id_rsa id_rsa.pub known_hosts
在这里插入图片描述
3.将authorized_keys拷贝到远端: /root/.ssh/
命令:scp ~ /.ssh/authorized_keys 192.168.75.131:~/.ssh/
[root@localhost .ssh]# scp authorized_keys 192.168.102.130:~/.ssh/
root@192.168.102.130’s password:
authorized_keys 100% 580 564.6KB/s 00:00
[root@localhost .ssh]# ssh root@192.168.102.130
在这里插入图片描述
同理在要登录的设备上也同样操作这三步

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值