简体   繁体   English

使用客户端(linux)中的资源在远程服务器中执行命令

[英]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): 评论:与发行版无关的部署脚本有时采用的一个技巧是嵌入一个静态的独立映像(确保内核兼容):

Live On Coliru 住在Coliru

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.

相关问题 使用 PHP 页面在远程 linux 服务器上执行安装的软件命令 - Execute an installed software command on a remote linux server using a PHP page 如何使用CGI和Perl的Net :: OpenSSH模块在远程Linux服务器上执行系统命令? - How to execute a system command on a remote Linux server using CGI and Perl's Net::OpenSSH module? 如何使用 symfony4 在远程 ubuntu 服务器上执行 linux 命令? - How to execute linux commands on a remote ubuntu server using symfony4? 无法在远程 Linux 主机上执行命令 - Unable to execute the command on the remote Linux hosts 使用SCP命令将文件从Linux服务器下载到客户端服务器 - Using SCP command to download files from Linux server to client server 在多台服务器上使用php和bash在Linux服务器上执行命令的问题 - problem with execute command on multiple servers using php and bash on linux server 如何在命令中传递多个参数以使用C / C ++和SSH在远程Linux计算机上执行exe - How to pass multiple arguments in a command to execute an exe on remote linux machine using C/C++ and SSH 使用Native Mac App在远程Linux机器上执行SSH命令。 (对象 - C) - Execute SSH Command on remote Linux Machine using Native Mac App. (Obj-C) 通过SSH在远程服务器上执行命令 - Execute command on remote server via ssh 如何使用linux命令行对远程数据库执行“ INSERT INTO”查询? - How to execute a “INSERT INTO” query to a remote database with linux command line?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM