我可以运行位于远程服务器上本地计算机上的bash脚本吗? [英] Can I run a bash script that is located on my local machine on a remote server?
本文介绍了我可以运行位于远程服务器上本地计算机上的bash脚本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些要在远程服务器上运行的本地脚本.我已经设置了ssh密钥对以启用无密码登录.
I have local scripts that I would like to run on a remote server. I have already set up ssh key pairs to enable login without a password.
我当前的方法是将脚本重新同步到服务器,然后运行它:
My current approach is to rsync the script to the server and then run it:
ssh user@remoteserver "rsync localserver:script.sh ./; ./script.sh; rm script.sh"
但是,这似乎是一种破解;有没有更用户友好的方法可以做到这一点?
However, this seems like a hack; Is there a more user friendly way to do this?
更新:既然有很多好的答案,那么有人可以通过提供理由来帮助我选择最佳"答案吗?
update: since there are so many good answers, can anyone help me select the 'best' one by providing rationale?
推荐答案
SSH将接受来自 stdin
ssh -T user@server <script.sh
编辑: -T禁用伪tty分配
这篇关于我可以运行位于远程服务器上本地计算机上的bash脚本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文