桥接,ssh免密登录

1.桥接

桥接就是把一台机器上的若干个网络接口连接起来,其结果是,其中一个网卡收到的报文会被复制给其他网卡发送出去。以使得网口之间的报文能够互相转发。
#创建一个桥接设备和会话

[root@localhost ~]# nmcli connection add type bridge con-name br1 ifname br1
#配置软件桥接网卡的IP地址、网关和地址获取方式
[root@localhost ~]# nmcli connection modify br1 ipv4.addresses 192.168.171.151/24
[root@localhost ~]# nmcli connection modify br1 ipv4.gateway 192.168.171.2
[root@localhost ~]# nmcli connection modify br1 ipv4.method manual
#添加从设备和会话到桥接设备
[root@localhost ~]# nmcli connection add type bridge-slave con-name br1-port0 ifname eno33554984 master br1
#启动从设备会话
[root@localhost ~]# nmcli connection up br1-port0 
#启动桥接会话
[root@localhost ~]# nmcli connection up br1

2.ssh:拒绝用户远程登录

[root@localhost ~]# vi /etc/ssh/sshd_config
#修改参数为no
PermitRootLogin no
#重启服务后生效,使用时使用普通用户进行登陆,需要使用root用户时再切换
[root@localhost ~]# service sshd restartsystemctl restart sshd.service

3.ssh免密登录

客户端

[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
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:cfYVGznusJVh6AsUzibcGrqAj5SQbjvwK7qrbEuta78 root@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|          .. .o. |
| .     . +. . =+ |
|o       =.B. oo+ |
|.. o   . O..o.+  |
|.o+ . . S  ..*   |
|oooo . .    o .  |
| +o.. .          |
|+oo.             |
|XO=E.            |
+----[SHA256]-----+
[root@localhost ~]# ssh 192.168.145.135
The authenticity of host '192.168.145.135 (192.168.145.135)' can't be established.
ECDSA key fingerprint is SHA256:hBns1U2NVfd3ZJpTsYlnD78SlNqmJ/E1W/Mjml3FhjM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.145.135' (ECDSA) to the list of known hosts.
root@192.168.145.135's password: 
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

Last login: Fri Nov 26 04:18:15 2021 from 192.168.145.

服务端

[root@localhost ~]# scp /root/.ssh/id_rsa.pub root@192.168.145.131:/root/.ssh/authorized_keys
The authenticity of host '192.168.145.131 (192.168.145.131)' can't be established.
ECDSA key fingerprint is SHA256:UQsHUboKtKIrMf4B/96XyS9RW/TQb8oN9QcD7buCKkU.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '192.168.145.131' (ECDSA) to the list of known hosts.
root@192.168.145.131's password: 
Permission denied, please try again.
root@192.168.145.131: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
lost connection
[root@localhost ~]# ssh 192.168.145.131
root@192.168.145.131's password: 
Permission denied, please try again.
root@192.168.145.131: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[root@localhost ~]# ssh 192.168.145.131
root@192.168.145.131's password: 
Permission denied, please try again.
root@192.168.145.131's password: 
root@192.168.145.131: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

如有错误,多多指正。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值