zoukankan      html  css  js  c++  java
  • centos无法通过ssh连接的解决

    系统环境是centos7,虚拟机环境下的。在使用ssh工具连接虚拟机的时候发现连接不上,用的是root

    先检查openssh-server是否安装:

    yum list installed | grep openssh-server

    查看日志/var/log/secure:

    显示相关的错误内容:

    PAM  1  more  authentication  failure;  logname =uid=0  euid=0  tty=ssh  ruser=  rhost=……

    pam_unix(login:session) :session  closed  for  user  root

    没有发现什么有用的信息

    查看22端口是否开启监听:

    netstat  -an |  grep  22

    发现没有listen,那么就是配置文件的问题了,

    打开/etc/ssh/sshd_config

    将选项中的Port  22取消注释,还有ListenAddress  0.0.0.0   ListenAddress  ::也取消注释,这些设置分别为监听端口、监听地址

    PermitRootLogin  no  的no改为yes(允许root开启远程登录)

    PasswordAuthentication  设置为yes(开启使用用户名和密码作为连接验证)

    (如果是ubuntu,找到 GSSAPI options 这一节,将下面两行注释掉:
      #GSSAPIAuthentication yes #GSSAPIDelegateCredentials no     然后重新启动)

    退出后重启sshd,service  sshd  restart

    同时要确保虚拟机系统和主机是通过局域网下的,能互相ping通的

    将ssh设为自启动:

    systemctl enable sshd.service

    检测ssh是否为自启动:

    systemctl list-unit-files | grep sshd

    Technorati Tags:

    参考:http://m.blog.csdn.net/article/details?id=52755571

  • 相关阅读:
    root----TH1
    linux debug
    python基础 文件操作
    linux下挂载硬盘
    安装双系统
    路由器相关
    007-python 获取网卡实时流量(转)
    ssh密钥登录失败(转)
    当while read line 遇到 ssh(转)
    python实用功能之001-邮件发送
  • 原文地址:https://www.cnblogs.com/simonid/p/6442741.html
Copyright © 2011-2022 走看看