• Mac上ssh localhost免密失败该如何解决


    前言

    今天准备利用自己的MBP搭建一个Hadoop小集群,结果在Mac上配置完ssh免密登陆的时候,使用ssh localhost测试时,总是弹出输入密码的提示。研究了一番, 记录下解决过程

    解决过程

    首先使用ssh -v localhost 观察debug信息, 发现publickey这一个阶段一直没有通过(如下):

    ...
    SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: rekey after 134217728 blocks
    debug1: Skipping ssh-dss key /Users/lestat/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
    debug1: SSH2_MSG_EXT_INFO received
    debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey,password,keyboard-interactive
    debug1: Next authentication method: publickey
    ...
    

    因为我生成的时dsa文件,而在日志中我们可以看到
    Skipping ssh-dss key /Users/lestat/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes,即该类型的密钥不被接受。
    于是马上查了一下为什么会这样, 原来新的openssh版本(7.0+)不推荐使用DSA密钥,而尽可能使用RSA密钥代替。
    当然如果你确实需要使用DSA密钥,则需要在客户端的配置文件~/.ssh/config中指明一下设置

    PubkeyAcceptedKeyTypes +ssh-dss
    

    当然考虑到以后可能会完全移除对该类型密钥文件的支持,于是决定使用RSA重新生成一遍密钥

    顺便记录一下几个与ssh相关的配置文件路径方便以后debug:

    • /etc/ssh/sshd_config
    • /etc/ssh/config
    • ~/.ssh/config
  • 相关阅读:
    C++一个类对象的大小计算
    C++多态及其实现原理
    C ++内存管理
    C++ 面向对象的三大特性和五个原则
    Liunx系统下的进程与线程
    selenium 常用方法
    Jenkins UI 自动化持续化集成测试
    教育数据挖掘可投的会议及期刊整理
    SonarQube-7.9.1+SQL Server2017在Windows环境下的安装与配置
    win10+Anaconda3+PyCharm 2019.1+python3.7-tensorflow-gpu1.13.1(RTX2080深度学习环境配置)
  • 原文地址:https://www.cnblogs.com/lestatzhang/p/10611301.html
Copyright © 2020-2023  润新知