我在 ec2 上为 ubuntu 完成了以下操作。
1) 我的安全组开放了 0-65000 端口
2)我通过运行这些命令来关闭防火墙
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
我还需要做什么才能让宗主与所有的奴隶一起工作?我如何测试它是否有效?我厌倦了 ssh 但仍然要求 key 。
ssh ec2-122-248-xxx-xxx.ap-southeast-1.compute.amazonaws.com erl
Permission denied (publickey).
最佳答案
这是我使用的 - 我首先编辑我的主机文件并确保我在那里有我所有机器的名称(你也可以使用 DNS,但我宁愿降低成本并使用内部 IP),然后我运行:
#!/bin/bash
myrsapub=`cat ~/.ssh/id_rsa.pub`
for i in <my_machine_names_space_delimited>; do
ssh $i -i ~/.ssh/<my_amazon_key> "echo $myrsapub | tee -a ~/.ssh/authorized_keys; ssh-keygen -t rsa << hereintime
hereintime; sudo hostname $i; exit" &> /dev/null
ssh $i "echo \"host *
user ubuntu
StrictHostKeyChecking no\" | tee -a .ssh/config; sudo sed -i.bak -e \"s/localhost/localhost $i/\" -e \"/$i/d\" /etc/hosts; echo \"# need to have ssh-agent running
eval \`ssh-agent\`
[ -e /home/ubuntu/.ssh/id_rsa.pub ] && ssh-add\" | tee -a ~/.bashrc" &> /dev/null
newhostline=`grep $i /etc/hosts`
ssh $i "sudo sed -i -e \"/$i/d\" /etc/hosts; echo $newhostline | sudo tee -a /etc/hosts" &> /dev/null
<LOAD_MASTER>=`grep <LOAD_MASTER> /etc/hosts` && ssh $i "sudo sed -i -e '/<LOAD_MASTER>/d' /etc/hosts" &> /dev/null
ssh $i "rm ~/.ssh/known_hosts; echo $<LOAD_MASTER> | sudo tee -a /etc/hosts; ssh <LOAD_MASTER> \"exit\"" &> /dev/null
ssh $i "cat ~/.ssh/id_rsa.pub" | tee -a ~/.ssh/authorized_keys
ssh $i "sudo hostname $i; exit"
done
关于ubuntu - tsung 和 ec2 - 如何允许 ubuntu 的无密码登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10737759/