Linux 如何通过 sftp 通过命令行上传文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21057895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:50:08  来源:igfitidea点击:

How can i upload file by command line via sftp?

linuxbashfile-uploadcommand-linesftp

提问by ss-t.c

I know how to get remote file via sftp.

我知道如何通过 sftp 获取远程文件。

ex:

前任:

sftp [email protected]:/path/to/file.txt localfile.txt

How can i upload file to remote server?

如何将文件上传到远程服务器?

(I need use this command in my bash script.)

(我需要在我的 bash 脚本中使用这个命令。)

采纳答案by vodolaz095

$ scp [email protected]:/path/to/file.txt localfile.txt

回答by HelpBox

Also think about using SSH public/private keys which can avoid you to have to enter a password for your automated file exchanges.

还可以考虑使用 SSH 公钥/私钥,这样可以避免您必须为自动文件交换输入密码。

You can use the command "ssh-keygen" to generate those keys.

您可以使用命令“ssh-keygen”来生成这些密钥。