首页 > 解决方案 > 我无法从脚本 ssh 进入 ec2 实例

问题描述

if [ $1 = 1 ]; then 
    echo "option 1"
    ssh -i swarm-nodes.pem ec2-user@18.255.33.
elif [ $1 = 2 ]; then 
    ssh -i swarm-nodes.pem ec2-user@18.188.124.
elif [ $1 = 3 ]; then 
    ssh -i swarm-nodes.pem ec2-user@3.137.220.
fi

将这些 ssh 行中的任何一个复制并粘贴到命令行中都可以正常工作。但是,当作为脚本运行时,即 ./myscript 1,它会超时。所以,我想我会在这里问

标签: amazon-web-servicesshellamazon-ec2

解决方案


我从一位好朋友那里听说,使用 DNS 名称而不是 IP 地址是可行的。


推荐阅读