如何使脚本连接和 运行 一些命令到 EC2?
How to make a script connect and and run some command to EC2?
我已经成功连接到 EC2,但是当它连接时,我的脚本 运行 在我的计算机上而不是在实例中。
ssh -i key.pem -oStrictHostKeyChecking=no ubuntu@XXXXX
echo "Hello World" # run on my computer
你可以这样做
ssh -i key.pem -oStrictHostKeyChecking=no ubuntu@XXXXX 'bash -s' < your_script.sh
并在 ec2 实例
上有一个本地文件 your_script.sh
,其中包含您想要 运行 的所有命令
我已经成功连接到 EC2,但是当它连接时,我的脚本 运行 在我的计算机上而不是在实例中。
ssh -i key.pem -oStrictHostKeyChecking=no ubuntu@XXXXX
echo "Hello World" # run on my computer
你可以这样做
ssh -i key.pem -oStrictHostKeyChecking=no ubuntu@XXXXX 'bash -s' < your_script.sh
并在 ec2 实例
上有一个本地文件your_script.sh
,其中包含您想要 运行 的所有命令