zoukankan      html  css  js  c++  java
  • 安装虚拟机后无法SSH远程连接

    1.安装虚拟机工具 vmware workstation

    2.创建一个虚拟机,系统版本是:CentOS-6.8-x86_64-LiveDVD

    3.系统安装完成后,选择网络为桥接模式,如图

     

     

     

    4.检查主机与虚拟机上的linux是否互相ping通,在主机上 cmd --> telnet 192.168.1.8(虚拟机ip) 22

    (如果主机无法使用telnet命令,则需要打开Telnet客户端,控制面板 --> 程序 --> 卸载或更改程序 --> 打开或关闭Windows功能 --> 选中 Telnet客户端)

    5.查看linux是否安装ssh服务

    登录 root 用户下

    命令:ssh localhost 

    如果提示 "ssh:connect to host localhost port 22:connection refused",就说明没有打开ssh服务或者未安装ssh服务.

    (1)如果linux系统是 ubuntu linux 版本,执行命令:sudo apt-get install openssh-server 安装ssh服务,在提示时都选择yes,然后会自动安装ssh服务.

    (2)如果linux系统是 centos linux 版本,查看ssh是否安装,执行命令:rpm -qa | grep ssh 

      如果安装过ssh服务则会出如图页面

      

      如果没有安装过ssh服务,则执行命令:yum install openssh-server 安装

    6.安装完成后输入命令(root用户下)

     启动ssh服务命令:service sshd start 

     重启SSH服务:service sshd restart

     停止ssh服务命令:service sshd stop 

     查看ssh服务22端口是否启动命令:netstat -antp | grep sshd

     查看ssh服务进程命令:ps -ef|grep ssh

    7.设置ssh服务为开机启动命令:chkconfig sshd on 

     设置ssh服务禁止开机启动命令:chkconfig sshd off 

    8.启动好ssh服务还是无法连接则要关闭防火墙

    #1.查看防火墙状态,出现下面显示表示防火墙开启
    [root@localhost ~]# service iptables status 
    Table: filter
    Chain INPUT (policy ACCEPT)
    num target prot opt source destination 
    1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 
    2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 
    3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 
    4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 
    5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
    
    Chain FORWARD (policy ACCEPT)
    num target prot opt source destination 
    1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
    
    Chain OUTPUT (policy ACCEPT)
    num target prot opt source destination
    
    #2.root用户下临时关闭防火墙
    [root@localhost ~]# service iptables stop 
    iptables: Setting chains to policy ACCEPT: filter [ OK ]
    iptables: Flushing firewall rules: [ OK ]
    iptables: Unloading modules: [ OK ]
    
    #3.查看状态,出现下面信息则防火墙为关闭状态
    [root@localhost ~]# service iptables status 
    iptables: Firewall is not running.

     (1)防火墙临时生效
      开启:service iptables start
      关闭:service iptables stop
     (2)防火墙永久性生效
      开启:chkconfig iptables on
      关闭:chkconfig iptables off

    9.设置虚拟机开机不启动:win+R键 --> 输入 msconfig --> 启动 --> 把vmware去掉

     

  • 相关阅读:
    求最小正整数x,A^x=1(mod M)求阶模板
    欧拉函数模板
    高次同余方程模板BabyStep-GiantStep
    Pollard-Rho大整数拆分模板
    Miller-Rabin大素数测试模板
    JSON教程基础
    11.@RequestParam @RequestBody @PathVariable 等参数绑定注解详解
    代码格式化
    使用FireFox插件RESTClient、HttpRequester模拟http(get post)请求
    SpringBoot入门最详细教程
  • 原文地址:https://www.cnblogs.com/skyessay/p/6401653.html
Copyright © 2011-2022 走看看