本文主要解决的问题:如何通过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. es6的理解

    目录:let——和var的区别const 特性:暂时性死区解构赋值 [] {}属性简洁函数简洁 属性表达式可以作为对象的属性名字符串扩展数组扩展对象扩展 Object.getPrototypeOf(实 ...

  2. 实战ELK(8) 安装ElasticSearch中文分词器

    安装 方法1 - download pre-build package from here: https://github.com/medcl/elasticsearch-analysis-ik/re ...

  3. 使用Python+turtle绘制同心圆

    问题描述:数学定义上是指:同一平面上同一圆心而半径不同的圆.简单来说就是:圆心相同半径不同的圆,如果几个圆的圆心是同一点,那么这几个圆就叫做同心圆. 本文使用turtle绘制一个类似“箭靶”的同心圆. ...

  4. 学习笔记:python3,PIP安装第三方库(2017)

    https://pip.pypa.io/en/latest/quickstart/ pip的使用文档 http://www.lfd.uci.edu/~gohlke/pythonlibs/   .whl ...

  5. WRF 安装备忘

    ▶ n 年前在笔记本上安装 WRF 的一个过程 ● 安装 cpp,csh,m4,quota,samba # apt-get install cpp csh m4 quota samba ● 网上教程有 ...

  6. [Linux]Ubuntu 16.04 远程桌面

    来源:http://blog.csdn.net/zz_1215/article/details/77921405 先吐槽一下,网上教的方法都是半桶水,都被教到连接后出现灰屏,只有这个博主(zz_121 ...

  7. websocket的子协议stomp协议

    stomp协议Spring实现 服务器注册EndPoint 用来与客户端建立websocket连接 websocket连接的建立应该与客户端与服务器之间的通道无关 jdk中 javax下的websoc ...

  8. 36_react_ui_antd

    1:最流行的开源react ui组件库 1.1:material-ui(国外) 1.2:ant-design(推荐:国内蚂蚁金服) 2.如何使用 方式一(页面引入): 在<head>标签内 ...

  9. python3集合练习(set)

    #集合是由不同元素组成;无序;集合中的元素必须是不可变类型;#s = {} 或者 s = set() 创建集合#update()扩展集合.返回值为Noneg1 = {'wcj','good','luc ...

  10. Cannot forward to error page for request ......

    今天现场报了以下问题: Cannot forward to error page for request [/order/search] as the response has already bee ...