zoukankan      html  css  js  c++  java
  • ssh连接亚马逊云报错:Permanently added ‘IP‘ (ECDSA) to the list of known hosts Permission denied

    报错详情

    在终端下通过ssh连接亚马逊云服务器具体报错如下:

    # wedo @ mjo in ~/.ssh [10:55:25] C:255
    $ ssh -i manjaro.pem ec2-user@xx.xx.xx.xx
    The authenticity of host 'xx.xx.xx.xx (xx.xx.xx.xx)' can't be established.
    ECDSA key fingerprint is SHA256:BzknItgds/gHJLtjp6kZ+wnAmlb2Op9ss7G3fonn/5I.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '1xx.xx.xx.xx' (ECDSA) to the list of known hosts.
    ec2-user@xx.xx.xx.xx: Permission denied (publickey).
    

    ssh连接AWS报错

    环境说明

    亚马逊云EC2创建操作系统实例的时候都需要你先创建一个密钥,然后ssh通过加载这个密钥来远程连接云服务器的终端.

    报错原因

    原因很简单:用户名错了
    把用户名改下就可以了
    一般操作系统(Linux)的用户名为:ec2-user
    使用这个用户名的操作系统一般为:AWS自己的Linux系统,RedHat操作系统
    另外Ubuntu系统的用户名为:ubuntu
    Centos系统的用户名为:centos

    总结

    可以把.pem认证文件放在${HOME}目录下的.ssh目录下
    比较麻烦的连接方式为:

    ssh -i xxx.pem ec2-user@xx.xx.xx.xx
    

     xxx.pem就是EC2实例的认证文件。

    成功登入aws服务器.

    命令好长啊,好难输入啊,有没有更好的方式呢?
    可以把xxx.pem认证文件add到ssh里后面就不用每次都指定了:
    xxx.pem文件预加载到ssh:

    ssh-add xxx.pem
    

    执行ssh-add时出现Could not open a connection to your authentication agent

    若执行ssh-add /path/to/xxx.pem是出现这个错误:Could not open a connection to your authentication agent,则先执行如下命令即可:

      ssh-agent bash
    更多关于ssh-agent的细节,可以用 man ssh-agent 来查看

    后面再连的时候只需要输入:

    ssh ec2-user@xx.xx.xx.xx
    

    还有有点长,有没有更好的方式呢?
    把这个命令指定一个别名,后面连的时候只输入别名主可以了:
    在.bashrc配置文件下添加上面的命令:

    vim .bashrc
    
    # 添加如下配置
    alias sshec2='ssh ec2-user@xx.xx.xx.xx'
    

    记得source一下:

    source .bashrc
    

    然后就可以输入下面的命令直接连了:

    sshec2
    

     OK,这样是不是就很简单了

    赞赏码

    非学,无以致疑;非问,无以广识

  • 相关阅读:
    Docker容器部署 Nginx服务
    trap 的用法 /etc/init.d/rcS trap :1 2 3 24
    android system setup and building (2)
    ubuntu 中建立tftp 服务器
    Mount nfs 报错Protocol not supported
    android system setup and building (1)
    mknod 详解
    linux 内核中已经定义的主设备号及查看设备设备号
    fstab 文件详解
    Linux根文件系统的挂载过程分析
  • 原文地址:https://www.cnblogs.com/lxwphp/p/15452693.html
Copyright © 2011-2022 走看看