如何在 AWS 上设置无密码 ssh
如何在 AWS 集群上的节点之间设置无密码 ssh
How do I setup passwordless ssh between nodes on AWS cluster
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何在 AWS 集群上的节点之间设置无密码 ssh
How do I setup passwordless ssh between nodes on AWS cluster
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
以下设置无密码身份验证的步骤已针对 Centos 和 Ubuntu 进行了彻底测试。
假设:
步骤:
创建新用户
将本地计算机上的 ~/.ssh/id_rsa.pub 文件的内容附加到 EC2 计算机上的 ~/.ssh/authorized_keys。
<前><代码>chmod -R 700 ~/.ssh
chmod 600 ~/.ssh/*
确保机器允许 sshing。在文件 /etc/ssh/sshd_config 中,确保取消注释包含“PasswordAuthentication yes”的行。如果您对此文件进行任何更改,请重新启动 sshd 服务:
您的无密码登录现在应该可以使用。在本地计算机上尝试以下操作:
让自己成为超级用户。打开
/etc/sudoers
。确保以下两行未注释:将您自己添加到轮组。
Following steps to setup password less authentication are tested thoroughly for Centos and Ubuntu.
Assumptions:
Steps:
Create a new user
Append contents of file ~/.ssh/id_rsa.pub on you local machine to ~/.ssh/authorized_keys on EC2 machine.
Make sure sshing is permitted by the machine. In file /etc/ssh/sshd_config, make sure that line containing "PasswordAuthentication yes" is uncommented. Restart sshd service if you make any change in this file:
Your passwordless login should work now. Try following on your local machine:
Making yourself a super user. Open
/etc/sudoers
. Make sure following two lines are uncommented:Add yourself to wheel group.
这可能会帮助某人
复制机器上的 pem 文件,然后将 pem 文件的内容复制到 .ssh/id_rsa 文件,您可以使用下面的命令或您自己的
尝试 ssh localhost 它应该可以工作,并且与集群中的其他机器相同
This may help someone
Copy the pem file on the machine then copy the content of pem file to the .ssh/id_rsa file you can use bellow command or your own
try ssh localhost it should work and same with the other machines in the cluster
我如何使 Passwordless shh 在两个实例之间工作如下:
创建 ec2 实例 - 它们应该位于同一子网中并具有相同的安全组
在它们之间打开端口 – 确保实例可以相互通信。使用默认安全组,该安全组具有与此案例相关的一条规则:
登录到您想要连接到其他实例的实例
运行:
1 ssh-keygen -t rsa -N "" -f /home/ubuntu/.ssh/id_rsa
生成新的 rsa 密钥。
将您的 AWS 私有密钥复制为 ~/.ssh/my.key(或您想要使用的任何名称)
确保将权限更改为 600
1 chmod 600 .ssh/my.key
将公钥复制到您想要无密码连接的实例
1 只猫 ~/.ssh/id_rsa.pub | ssh -i ~/.ssh/my.key [电子邮件受保护] "猫>>〜/.ssh/authorized_keys“
如果您测试另一台机器的无密码 ssh,它应该可以工作。
1 ssh 10.0.0.X
how I made Paswordless shh work between two instances is the following:
create ec2 instances – they should be in the same subnet and have the same security group
Open ports between them – make sure instances can communicate to each other. Use the default security group which has one rule relevant for this case:
Log in to the instance you want to connect from to the other instance
Run:
1 ssh-keygen -t rsa -N "" -f /home/ubuntu/.ssh/id_rsa
to generate a new rsa key.
Copy your private AWS key as ~/.ssh/my.key (or whatever name you want to use)
Make sure you change the permission to 600
1 chmod 600 .ssh/my.key
Copy the public key to the instance you wish to connect to passwordless
1 cat ~/.ssh/id_rsa.pub | ssh -i ~/.ssh/my.key [email protected] "cat >> ~/.ssh/authorized_keys"
If you test the passwordless ssh to the other machine, it should work.
1 ssh 10.0.0.X
我如何在两个实例之间设置无密码身份验证如下:
target_instance_key.pem
内并保存文件。target_instance_key.pem
的权限,即chmod 600 target_instance_key.pem
ssh-keygen -t rsa
创建 rsa 密钥>ssh-copy-id -f "-o IdentityFile ~/.ssh/target_instance_key.pem" ubuntu@
,指纹类型yes
并输入。注意:
server_instance 可以是任何计算机(即 EC2 实例(或)您的本地计算机)。
How Did I Setup Password-Less Authentication between two Instances is the following:
cd ~/.ssh
and create a filevim target_instance_key.pem
and paste the contents of target_instance access key (which is created during launch of target_instance in AWS console) insidetarget_instance_key.pem
and save the file.target_instance_key.pem
i.echmod 600 target_instance_key.pem
ssh-keygen -t rsa
ssh-copy-id -f "-o IdentityFile ~/.ssh/target_instance_key.pem" ubuntu@<TARGET_INSTANCE-PUBLIC-IP>
and for fingerprint typeyes
and enter.ssh ubuntu@<TARGET_INSTANCE_PUBLIC-IP-ADDRESS>
and you have Logged in to the target_instance from server_instance through Password-Less Authentication.NOTE :
server_instance can be any machine(i.e, EC2 instance (or) your local machine).
您可以使用 ssh 密钥,如下所述:
http://pkeck.myweb.uga.edu/ssh/
you can use ssh keys like described here:
http://pkeck.myweb.uga.edu/ssh/