UNIX ssh脚本,在远程服务器上运行命令 [英] UNIX ssh script, running commands on remote server

查看:372
本文介绍了UNIX ssh脚本,在远程服务器上运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个自动登录到远程服务器并抓取服务器上的文件的脚本。该脚本已经登录到服务器,但是该命令不在该计算机上运行。一旦我从远程服务器断开连接,命令就在客户端机器上运行。

I would like to create a script that automatically logs into a remote server and grabs a file on the server. The script already logs into the server however the commands are not run on that machine. Once I disconnect from the remote server, the commands are run on the client machine.

!/bin/sh
ssh -o PreferredAuthentications=publickey brjones@server.com
cd ~/folder
"i would like to grab file and copy it to client machines folder"

编辑:我不知道你是否注意到,但我使用无密码连接到远程服务器使用ssh和keygeneration。我欣赏的想法,但我正在寻找可能的管道命令或在客户端上使用脚本在远程服务器上运行命令。我意识到远程服务器没有访问客户端脚本,但是我很好奇,如果可以通过ssh连接管道命令。

I am not sure if you noticed but I am used a passwordless connection to the remote server using ssh and keygeneration. I appreciate the ideas but I am looking to possibly pipe commands or run commands on the remote server with the script on the client. I realize that the remote server does not have access to the client script, however I was curious if it was possible to pipe the commands through the ssh connection.

推荐答案

您应该使用 scp (安全副本),而不是 ssh (安全shell )。

You should be using scp ("secure copy") rather than ssh ("secure shell").

这篇关于UNIX ssh脚本,在远程服务器上运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆