如何从命令行下载文件?通过ssh?

And*_*rew 22 ssh command-line ubuntu

我想将文件从远程服务器下载到我的本地驱动器,并从命令行执行此操作。我也希望能够通过 SSH 做到这一点。我怎样才能做到这一点?

注:远程服务器为Ubuntu,本地为Mac OS X

Ahe*_*Ahe 30

使用scp-command,它运行在 SSH 之上。例子:

scp username@remote.host:/path/to/file localfile
Run Code Online (Sandbox Code Playgroud)

它也以另一种方式工作

scp localfile username@host:/path/remotefile
Run Code Online (Sandbox Code Playgroud)

用户名、路径和文件名可以省略(但不能省略:!)。

正如 Iain 所说,SFTP 也可以工作,但我倾向于使用scpcp类似的用法。