本文主要解决的问题:如何通过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)的更多相关文章

  1. 用xshell连接VMware虚拟机中安装的Centos7系统

    首先要保证你安装的Centos7系统的网路适配器使用的桥接模式,这个模式允许你安装再虚拟机中的Centos系统有一个自己的ip地址. 然后再虚拟机中登录你的Centos系统,用ip addr命令查看你 ...

  2. 使用xshell连接本地虚拟机中的Linux问题

    xshell 连接虚拟机中Linux报错: Could not connect to '192.168.8.120' (port 22):Connection failed. 原因:虚拟机中Linux ...

  3. 配置SecureCRT连接本地虚拟机中的Linux系统

    转自:http://www.pythoner.com/196.html 由于平时公司开发时都是使用SecureCRT连接的Linux服务器,所以也想使用SecureCRT在自己电脑上连接本地虚拟机中的 ...

  4. xshell连接本地虚拟机中的centos

    1. 一开始Xshell连接不上(设置为DHCP 动态IP)虚拟机上的centos8 参考这篇博文,将centos上的DHCP改为static 静态IP xshell连接本地虚拟机中的centos 2 ...

  5. VMware虚拟机中为Linux 添加虚拟硬盘(VirtualBox方法类似)

    修改1:2014-06-24 11:38:21 Linux添加硬盘是在原来安装的硬盘空间不够或者需要使用其他硬盘上的东西时候的解决办法,因为大多数初学者习惯使用虚拟机,这里以在Vmware虚拟机中实现 ...

  6. 配置SecureCRT连接VirtualBox虚拟机中的Linux环境

    在实际的运维中我们常常使用SecuriteCRT来远程控制Linux服务器.下面将详细介绍windows 7下通过VirtualBox搭建linux开发环境,并最终通过SecurityCRT来远程访问 ...

  7. 如何使用 SSH 连接 VMWare 虚拟机中的 Ubuntu

    环境:VMWare Player 5.0.2,Ubuntu 13.10  VMWare共有3种网络连接模式,分别是: 1. bridged(桥接模式):虚拟机将直接连接到物理局域网,使自身独立于宿主机 ...

  8. Secure CRT连接VMware虚拟机中的CentOS 7

    操作步骤: 1.安装Centos 7   虚拟机设置==>NetworkAdapter===>选择NAT(共享主机的IP地址), CTRL+ALT+F1切换到图形界面 选择右上角以太网打开 ...

  9. VMware虚拟机中调整Linux分区大小——使用gparted

    虚拟机分配了50G大小的空间,最近发现不够用,于是将扩展一下分区的大小,查了几种方法都不是很好,后来借助了gparted分区空间完成了,这个工具简单,方便,下面就简单的介绍一下.扩展分区主要要分为两步 ...

随机推荐

  1. 关于vim的常用操作

    vim常用操作和使用技巧 vi是linux与unix下的常用文本编辑器,其运行稳定,使用方便,本文将分两部分对其常用操作技巧和配置进行阐述,其中参考了网上的一些文章,对作者表示感谢 PART1 操作技 ...

  2. 数据库中id为自增

    使用find_and_modify函数可以设置mongo的id为自增 且可以支持原有的高并发操作,find_and_modify函数完成更新查找两个操作其是原子性的操作 代码:(auto_id.py) ...

  3. 【MySQL】5.7 复制

    参考:http://www.cnblogs.com/zhoujinyi/p/5704567.html 参考:http://www.innomysql.com/article/25656.html 参考 ...

  4. IntelliJ IDEA 打开项目红色

    项目目录红色主要是有版本控制所导致的,解决办法就是解除版本控制 点击File->Settings...->Version Control 项目会重新编译,项目目录红色会消失

  5. jQuery中event.target和this的区别

    http://www.cnblogs.com/hhsy/p/5647930.html    该链接有详细讲解

  6. python2操作MySQL

    #coding=utf-8   import MySQLdb   conn = MySQLdb.connect(host='localhost',user='root',passwd='123456' ...

  7. docx httpheader头设置

    设置contentType内容类型如下: Extension MIME Type .doc application/msword .dot application/msword .docx appli ...

  8. swift 加载 本地html 和 网络路径

    先上代码: xcode 9.4  ios 11.4 import UIKit import WebKit class RootViewController: UIViewController, WKN ...

  9. MATLAB 出一张好看的图

    1.坐标轴的视点(viewpoint):从哪个方向看整个坐标系统,这决定了坐标轴的方向和位置,通过view函数实现视点的设置:view([z y ]):(将坐标系统想象为一座房子,而自己是个会飞的天使 ...

  10. 批处理BAT运行不显示DOS窗口的方法

    新建记事本,写入下面内容 set ws=wscript.createobject("wscript.shell") ws.run "D:\scripts\svn-upda ...