如何通过SSH工具(SecureCRT、XShell)连接Vmware虚拟机中的Linux(CentOS7)
本文主要解决的问题:如何通过SSH工具连接到VMWare中改的Linux系统(CentOS7)
核心内容:Linux中需要安装openssh-server,并且启动了openssh-server服务。
如果没有安装,需安装;
如果没有启动,需要启动起来。
步骤:
1.检查CentOS中是否安装了openssh-server
在终端中输入: yum list installed | grep openssh-server
此处显示已经安装了 openssh-server,如果又没任何输出显示表示没有安装 openssh-server,通过输入 yum install openssh-server
来进行安装openssh-server
2.切换到目录: /etc/ssh/,使用vim编辑器打开sshd_config配置文件,开启监听端口,监听地址。
主要的几句话需要放开,去掉#号:
#将文件中,关于监听端口、监听地址前的 # 号去除
Port 22
AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::
#然后开启允许远程登录
PermitRootLogin yes
#最后,开启使用用户名密码来作为连接验证
PasswordAuthentication yes
以下是实际操作:可以比照参考,下面是已修改好的,可以使用ssh工具链接的的sshd_config配置文件。
打开sshd_config配置文件并编辑:
[root@sparkmaster ssh]# vi sshd_config
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 22
AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::
HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no
# Kerberos options
3.按ESC键,退出编辑模式,输入 :wq 回车,保存刚才的编辑操作。
4.开启sshd 服务,输入 sudo service sshd start
或者root用户下直接输入 service sshd start
5.检查 sshd 服务是否已经开启,输入ps -e | grep sshd
如果输出:
2740(进程ID,每台机器可能不同,忽略它) 00:00:00 sshd
说明sshd服务已经启动成功。
如果linux中未安装netstat,则无法使用下面这个命令查看22端口是否开启监听
或者输入netstat -an | grep 22 检查 22 号端口是否开启监听
6. 在Vmware Workstation中,查看CentOS7的属性,发现网络连接方式是采用的 NAT 方式连接的
7.在Vmware Workstation中,点击编辑=》虚拟网络编辑器,进入虚拟网络编辑器,查看发现 NAT 模式的连接采用的网络适配器名称为VMnet8。
8.在 windows 主机中,在命令行中输入ipconfig 查看主机IP,找到 VMnet8 的连接信息,此处 ip 为192.168.30.1
9.在CentOS中,输入ifconfig查看网络连接地址,发现CentOS的网络地址为192.168.112.128
10.在CentOS中,输入ping 192.168.30.1 测试是否能连通主机,发现可以连通
11.在主机中,输入 ping 192.168.112.128,测试主机是否能连通CentOS,发现连不通,需要执行12,13这两步。
如果可以连得通,可以直接跳至第14 步
12.在主机,打开网络配置,选择网络适配器 VMnet8 的 TCP/IPv4 的属性,进行一下网络配置
配置IP地址:
使用下面的Ip地址:
IP地址:192.168.112.1
子网掩码:255.255.255.0
默认网关:192.168.112.255
要求子网掩码、默认网关均和CentOS一致,并将IP地址修改为 192.168.112.1,即保证主机的 IP 和 CentOS 的 IP 在同一网络区段中
13.再在主机中,输入 ping 192.168.112.128,已经可以连接得通了
14.在SSH工具(此处使用的XShell)中,新建连接,输入 CentOS 的 IP 地址、用户名、密码即可连接成功
XShell 客户端 :hostname:192.168.112.128,使用SSH协议,22端口。
SecureCRT客户端:hostname:192.168.112.128,使用SSH2协议,22端口。
15.为了免去每次开启 CentOS 时,都要手动开启 sshd 服务,可以将 sshd 服务添加至自启动列表中,输入s
ystemctl enable sshd.service
可以通过输入systemctl list-unit-files | grep sshd,查看是否开启了sshd 服务自启动
如果输出内容包含:
sshd.service enabled
说明服务已添加到自启动列表中了。
参考文章:linux ssh 虚拟机下CentOS7开启SSH连接
如何通过SSH工具(SecureCRT、XShell)连接Vmware虚拟机中的Linux(CentOS7)的更多相关文章
- 用xshell连接VMware虚拟机中安装的Centos7系统
首先要保证你安装的Centos7系统的网路适配器使用的桥接模式,这个模式允许你安装再虚拟机中的Centos系统有一个自己的ip地址. 然后再虚拟机中登录你的Centos系统,用ip addr命令查看你 ...
- 使用xshell连接本地虚拟机中的Linux问题
xshell 连接虚拟机中Linux报错: Could not connect to '192.168.8.120' (port 22):Connection failed. 原因:虚拟机中Linux ...
- 配置SecureCRT连接本地虚拟机中的Linux系统
转自:http://www.pythoner.com/196.html 由于平时公司开发时都是使用SecureCRT连接的Linux服务器,所以也想使用SecureCRT在自己电脑上连接本地虚拟机中的 ...
- xshell连接本地虚拟机中的centos
1. 一开始Xshell连接不上(设置为DHCP 动态IP)虚拟机上的centos8 参考这篇博文,将centos上的DHCP改为static 静态IP xshell连接本地虚拟机中的centos 2 ...
- VMware虚拟机中为Linux 添加虚拟硬盘(VirtualBox方法类似)
修改1:2014-06-24 11:38:21 Linux添加硬盘是在原来安装的硬盘空间不够或者需要使用其他硬盘上的东西时候的解决办法,因为大多数初学者习惯使用虚拟机,这里以在Vmware虚拟机中实现 ...
- 配置SecureCRT连接VirtualBox虚拟机中的Linux环境
在实际的运维中我们常常使用SecuriteCRT来远程控制Linux服务器.下面将详细介绍windows 7下通过VirtualBox搭建linux开发环境,并最终通过SecurityCRT来远程访问 ...
- 如何使用 SSH 连接 VMWare 虚拟机中的 Ubuntu
环境:VMWare Player 5.0.2,Ubuntu 13.10 VMWare共有3种网络连接模式,分别是: 1. bridged(桥接模式):虚拟机将直接连接到物理局域网,使自身独立于宿主机 ...
- Secure CRT连接VMware虚拟机中的CentOS 7
操作步骤: 1.安装Centos 7 虚拟机设置==>NetworkAdapter===>选择NAT(共享主机的IP地址), CTRL+ALT+F1切换到图形界面 选择右上角以太网打开 ...
- VMware虚拟机中调整Linux分区大小——使用gparted
虚拟机分配了50G大小的空间,最近发现不够用,于是将扩展一下分区的大小,查了几种方法都不是很好,后来借助了gparted分区空间完成了,这个工具简单,方便,下面就简单的介绍一下.扩展分区主要要分为两步 ...
随机推荐
- arrayList转换为数据
ArrayList arrayList = SetTools.loadfile(path); string[] str = (string[])arrayList.ToArray(typeof(str ...
- day72Django之ORM
Django框架之ORM(day72)一 ORM即Object Relational Mapping,全称对象关系映射. 1 不用写sql,不会sql的人也可以写程序 2 开发效率高 3 可能sql的 ...
- [论文阅读]Object detection at 200 Frames Per Second
本文提出了一个有效且快速的目标检测器,该目标检测器得速度可以达到200+fps,在Pascal VOC-2007上的mAP比Tiny-Yolo-v2高出14. 本文从以下三个方面对网络进行改进. 网络 ...
- (python基础 函数)
关键字参数:关键字参数和函数调用关系紧密,函数调用使用关键字参数来确定传入的参数值.使用关键字参数允许函数调用时参数的顺序与声明时不一致,因为 Python 解释器能够用参数名匹配参数值 必需参数:必 ...
- 20165205 《网络对抗技术》 Exp0 Kali安装
20165205 <网络对抗技术> Exp0 Kali安装 一.下载及安装 打开官方下载网站 我下载的是vm版,64位,如下图 之后继续点击 之后就可以等待下载成功了,成功之后找到.vmx ...
- nginx配置多个域名
1.原来的80端口改掉,下面配置: server { listen 80; server_name *.pobohn.com; location / { proxy_pass http://local ...
- vscode更新后 ctrl+v、ctrl+c、ctrl+x不可以用了,而且光标变粗,已解决
vscode更新后 ctrl+v.ctrl+c.ctrl+x不可以用了,而且光标变粗,已解决 原因是 你的vscode里面安装了 vim ,简单粗暴的方法就是直接卸载掉就可以了. 卸载vim方法:在v ...
- 在windows 10 上使用aspnet_regiis.exe -i 命令报 “此操作系统版本不支持此选项” 的解决办法
用CMD窗口在C:\Windows\Microsoft.NET\Framework64\v4.0.30319下使用命令aspnet_regiis -i 报错: “此操作系统版本不支持此选项” .结果是 ...
- ReactNative 学习笔记
1. react-native引入第三方库时报Command `run-android` unrecognized: 在使用第三方库tab-navigator时调用: npm install reac ...
- redis bind的坑
启动redis时,发现外网访问不了 检查以下方面 1. ping redis 的ip 2. 检查防火墙端口是否开放3. bind bind bind指的是绑定哪个ip可以访问 bind 要填写你自己r ...