[英]Execute command in remote server using resources in client (linux)
I want to execute command in a remote server using resoures in client (both sides are linux), ex: in client I have a shell file(ex: /home/john/helloworld.sh), I connect to a remote server using ssh, then I want to run this shell file in remote server without uploading it to this server 我想在客户端使用resoures在远程服务器上执行命令(双方都是linux),例如:在客户端我有一个shell文件(例如:/home/john/helloworld.sh),我使用ssh连接到远程服务器,然后我想在远程服务器上运行此shell文件,而不将其上传到此服务器
anyone have any solution for this problem? 谁有这个问题的解决方案?
edit: thanhk sehe, now I can run shell file from client, but I want to run ac program, any way to do it? 编辑:thanhk sehe,现在我可以从客户端运行shell文件,但我想运行ac程序,任何方式都可以吗?
ssh user@remote sh - < mylocalscript.sh
Test it directly on your machine: 直接在您的机器上测试:
echo ls | ssh localhost sh -
UPDATE UPDATE
To the comment: a trick sometimes employed by distro-agnostic deployment scripts is to embed a static, standalone image (make sure the kernel is compatible): 评论:与发行版无关的部署脚本有时采用的一个技巧是嵌入一个静态的独立映像(确保内核兼容):
The base64 data there was generated by doing 通过这样做生成了base64数据
gcc -static -static-libgcc -Os -g0 -x c - <<< 'int main() {puts("hello world");return 0;}' -o standalone
dd if=standalone | gzip | base64 -w240
Tricky one and using scp to copy the file would be the most obvious solution. 棘手的并使用scp复制文件将是最明显的解决方案。 However depending on the access level you have on the remote server, you could look at SSHFS (Wikipedia link) which will allow you to mount the filesystem with the script in it.
但是,根据您在远程服务器上的访问级别,您可以查看SSHFS(Wikipedia链接) ,它将允许您使用脚本安装文件系统。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.