使用MobaXterm/winTerm之类的工具连接虚拟机时报错Permission denied或者Access denied的解决办法

本文详细介绍了如何在虚拟机中设置VMnet6的DHCP,手动分配静态IP,使用nmcli设置接口IP,修改sshd_config以允许SSH登录,以及使用MobaXterm等工具连接。
摘要由CSDN通过智能技术生成

一、虚拟机设置:

1.将点击【编辑】---> 【虚拟网络编辑器】

4350cce5b7eb4b6c842d2b10f9067ba5.png

2.添加VMnet6

1)点击【DHCP设置】--->添加网络--->选中【仅主机模式】+【将主机虚拟适配器连接到此网络】

2)子网ip写“192.168.66.0”

3)点击右下角【应用】按钮

40531bd396a14b538e94b927b8184844.png

3.点击【虚拟机】--->【设置】--->【虚拟机设置】,具体内容如下所示:

f6bbca51ea4646f399e83b1685dc1eab.png

235de7dd9e5f48afab7c144d24c027cc.png

二、使用nmcli设置ip地址

1)nmcli connection modify eth0 ipv4.method manual ipv4.addresses 192.168.66.2/24 autoconnect yes
2)nmcli connection up eth0
3)ip a s

三、修改/etc/ssh/sshd_config文件

1. 直接在文件中修改:

1) vim /etc/ssh/sshd_config
在该文件使用末行模式:
第一步:/PermitRootLogin====>enter回车=》找到PermitRootLogin的位置修改为PermitRootLogin yes

第二步:使用/PasswordAuthentication====>enter回车=》找到PasswordAuthentication的位置修改为
PasswordAuthentication yes
2)systemctl restart sshd #启动sshd

2.或者写一个简单的shell脚本

1)allow_ssh_login.sh文件内容如下

#!/bin/bash
echo '
#easy shell code to allow ssh login---start-----
PermitRootLogin yes
PasswordAuthentication yes
#easy shell code to allow ssh login---end-----
' >> /etc/ssh/sshd_config

2)给allow_ssh_login.sh文件执行权限

chmod +x allow_ssh_login.sh

使用./allow_ssh_login.sh执行该脚本

3) 启动sshd

systemctl restart sshd

四、使用MobaXterm或者winTerm,xshell等工具连接

1d742a07260a42aab38c237edf47d193.png

886c28118e0e4731bd5dfea166713273.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值