如何通过ssh将文件从一台机器传输到另一台机器?


2

我的教授希望我们给他发送电子邮件源文件,但他希望我们使用vi编辑ssh。如何通过ssh将文件从一台机器传输到另一台机器?

Answers:


5

要通过ssh传输文件,您应该使用该scp命令。

基本用法是:

[you@localhost ~]$ scp examplefile yourusername@remoteserver:/home/yourusername/

它将通过SSH将文件复制examplefile到该位置的远程服务器/home/yourusername/examplefile

更具体的例子:

[Moshe@localhost ~/mywork]$ scp thework.zip Moshe@192.168.1.21:/home/Moshe/

假设您的本地文件是,/home/Moshe/mywork/thework.zip并且您有权登录到服务器192.168.1.21并在远程目录中写入/home/Moshe

您将以远程服务器/home/Moshe/thework.zip上复制的文件结束。

如果您不是在Linux或本地任何基于Unix的系统上工作(例如,您通常在Windows上),那么像WinSCP这样的工具将使您能够借助图形界面通过SSH传输文件。


@Zertin - 我在一台远程服务器上有一个.tar.gz文件。我可以一次解压缩和解压缩文件并将文件从一台服务器复制到另一台服务器吗?
MontyPython 2015年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.