zoukankan      html  css  js  c++  java
  • centos7远程连接(开启SSH)

    centos7远程连接(开启SSH)

    centos7 64位操作系统

    一.先查看网络是否连接,使用ping www.baidu.con ,试试是否能ping通网站,可以代表网络已经连接。

    [root@localhost home]# ping www.baidu.com
    PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data.
    64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=128 time=40.1 ms
    64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=128 time=96.2 ms
    64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=128 time=43.5 ms
    

    ping通了,说明网络连接没有问题。

    二.可以先输入命令netstat -an| grep ssh,查看ssh是否开启,如果开启就可以直接远程连接.

    [root@localhost home]# netstat -an |grep ssh
    .......................
    ........................
    

    显示没有开启

    三.开启SSH连接

    1.要确保centos7安装了openssh-server,在终端输入yum list installed | grep openssh-server

    [root@localhost hjw]# yum list installed |grep openssh-server
    

    我这显示已经安装了,如果没有输出显示表明没有安装,通过输入yum install openssh-server进行安装。

    [root@localhost hjw]# yum install openssh-server
    

    2.安装好后,使用vim打开/etc/ssh/下面的sshd_config文件进行更改

    [root@localhost hjw]# vim /etc/ssh/sshd_config
    

    编辑打开的文件:

    .........
    ........
    Port 22          #将改行前面的#键去掉,开启22端口
    #AddressFamily any
    ListenAddress 0.0.0.0 #将改行前面的#键去掉
    ListenAddress ::      #将改行前面的#键去掉
    .......
    .........
    #LoginGraceTime 2m
    PermitRootLogin yes         #将改行前面的#键去掉  允许远程登录
    #StrictModes yes
    ...........
    ..............
    #PasswordAuthentication yes
    #PermitEmptyPasswords no
    PasswordAuthentication yes     #将改行前面的#键去掉,这是开启用户名和密码登录
    

    保存文件后退出

    3.编辑完后要开启sshd服务,输入sudo service sshd start

    [root@localhost hjw]# sudo service sshd start
    Redirecting to /bin/systemctl start sshd.service
    

    4.检查22端口是否开通,输入命令netstat -an | grep 22

    [root@localhost hjw]# netstat -an| grep 22
    tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN     
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
    tcp6       0      0 :::22                   :::*                    LISTEN  
    

      

    转载自:https://blog.csdn.net/hjw1314kl/article/details/102968761

  • 相关阅读:
    Luogu 3119 [USACO15JAN]草鉴定Grass Cownoisseur
    Luogu 4514 上帝造题的七分钟
    Luogu 1484 种树
    Luogu【P2904】跨河(DP)
    Luogu【P2065】贪心的果农(DP)
    Luogu【P1725】琪露诺(单调队列,DP)
    二分图匹配
    单调队列
    Tarjan的强联通分量
    手写堆
  • 原文地址:https://www.cnblogs.com/ZeroSunny/p/14900454.html
Copyright © 2011-2022 走看看