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

查看:20
本文介绍了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 和密钥生成与远程服务器建立无密码连接.我很欣赏这些想法,但我希望使用客户端上的脚本在远程服务器上传输命令或运行命令.我意识到远程服务器无法访问客户端脚本,但是我很好奇是否可以通过 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(安全外壳").

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

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

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