【问题标题】:How do I setup passwordless ssh on AWS如何在 AWS 上设置无密码 ssh
【发布时间】:2011-06-03 09:40:53
【问题描述】:

如何在 AWS 集群上的节点之间设置无密码 ssh

【问题讨论】:

    标签: ssh amazon-ec2


    【解决方案1】:

    您可以使用此处描述的 ssh 密钥: http://pkeck.myweb.uga.edu/ssh/

    【讨论】:

      【解决方案2】:

      这可能对某人有帮助

      复制机器上的pem文件,然后将pem文件的内容复制到.ssh/id_rsa文件,你可以使用下面的命令或你自己的

      cat my.pem > ~/.ssh/id_rsa
      

      尝试 ssh localhost 它应该可以工作并且与集群中的其他机器相同

      【讨论】:

      • 在 Amazon AWS EC2 中运行 CentOS 6.5。这完美!
      • 从Mac终端访问时也只需要添加用户名
      【解决方案3】:

      以下步骤设置无密码身份验证已针对 Centos 和 Ubuntu 进行了彻底测试。

      假设:

      1. 您已经可以访问您的 EC2 计算机。可能正在使用 pem 密钥,或者您拥有具有 root 权限的 unix 用户的凭据。
      2. 您已经在本地计算机上设置了 RSA 密钥。私钥和公钥分别位于“~/.ssh/id_rsa”和“~/.ssh/id_rsa.pub”。

      步骤:

      1. 以 root 用户身份登录您的 EC2 机器。
      2. 创建一个新用户

        useradd -m <yourname> 
        sudo su <yourname>
        cd 
        mkdir -p ~/.ssh
        touch ~/.ssh/authorized_keys
        

        将本地机器上的文件 ~/.ssh/id_rsa.pub 的内容附加到 EC2 机器上的 ~/.ssh/authorized_keys 中。

        chmod -R 700 ~/.ssh
        chmod 600 ~/.ssh/*
        
      3. 确保机器允许 sshing。在文件 /etc/ssh/sshd_config 中,确保取消注释包含“PasswordAuthentication yes”的行。如果您对此文件进行任何更改,请重新启动 sshd 服务:

        service sshd restart # On Centos
        service ssh restart # On Ubuntu
        
      4. 您的无密码登录现在应该可以工作了。在您的本地机器上尝试以下操作:

        ssh -A <yourname>@ec2-xx-xx-xxx-xxx.ap-southeast-1.compute.amazonaws.com
        
      5. 让自己成为超级用户。打开/etc/sudoers。确保以下两行未注释:

        ## Allows people in group wheel to run all commands
        %wheel ALL=(ALL)       ALL
        
        ## Same thing without a password
        %wheel ALL=(ALL)       NOPASSWD: ALL
        

        将自己添加到车轮组。

        usermod -aG wheel <yourname> 
        

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-10-31
        • 2017-12-14
        • 1970-01-01
        • 2012-05-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多