使用Mac OS X的Bash脚本中的SFTP命令 [英] SFTP command in Bash script with Mac OS X

查看:126
本文介绍了使用Mac OS X的Bash脚本中的SFTP命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Mac主机上的SFTP和SSH将文本文件传输到远程PC(freeSSH).这两个连接在本地网络中.

I need to transfer a text file to a remote PC (freeSSH) using SFTP and SSH from a Mac host. These two are connected in a local network.

有没有办法从Bash脚本中运行SFTP命令(提供用户名和密码)?

So is there a way to run an SFTP command (with the username and password provided) from inside the Bash script?

我已经用expect尝试了一些脚本,但是没有得到任何结果.

I already tried some scripting with expect, but I didn't get any results.

我找到了类似的帖子,

I found a similar post, How to run the sftp command with a password from a Bash script, but it is for Linux. I have a Mac.

推荐答案

您也可以在Mac上下载并安装sshpass.从此下载链接

You can download and install sshpass on Mac as well. Get the latest version source from this download link

我的链接答案中有使用sshpass的其余步骤.

Rest of the steps on using sshpass are there in the linked answer of mine.

这篇关于使用Mac OS X的Bash脚本中的SFTP命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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