Shell脚本程序从linux远程服务器下载文件

时间:2014-04-24 03:30:51

标签: shell sftp

我是shell脚本的新手,我想从linux远程服务器下载一些文件,所以我该怎么办呢。这个远程服务器是基于ssh的。

1 个答案:

答案 0 :(得分:-1)

首先,ftp服务是从远程服务器获取文件的更好选择。

如果只有sshd服务可用,那么您可以使用基于ssh的命令sftpscp。 但是,使用sftpscp命令将调用交互式密码提示,这是shell脚本中的问题 - >您必须向expect命令寻求帮助。见Automate scp file transfer using a shell script

expect之外,您还可以在两台服务器之间设置信任关系,然后您可以使用scp而无需密码。见http://www.linuxproblem.org/art_9.html