Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如何使脚本连接并运行一些命令到EC2?_Amazon Web Services_Ubuntu 16.04 - Fatal编程技术网

Amazon web services 如何使脚本连接并运行一些命令到EC2?

Amazon web services 如何使脚本连接并运行一些命令到EC2?,amazon-web-services,ubuntu-16.04,Amazon Web Services,Ubuntu 16.04,我已经成功连接到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 ssh-i key.pem-

我已经成功连接到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
ssh-i key.pem-oStrictHostKeyChecking=noubuntu@XXXXX“bash-s”

并且有一个本地文件
您的_script.sh
,其中包含您想要在ec2实例上运行的所有命令

我认为a-t标志对于保持sesson是必要的