场景1:
例如:将服务器A:username@remote_host_A
中的文件/path/to/remote/file
到从服务器Busername@remote_host_B
的文件夹下:/path/to/remote/directory
应该在服务器A上运行 scp 命令:
scp /path/to/remote/file username@remote_host_B:/path/to/remote/directory
如果服务器B使用了非默认的SSH端口,你需要指定端口号,例如:
scp -P <port> /path/to/remote/file username@remote_host_B:/path/to/remote/directory
场景2:
例如:将服务器A:username@remote_host_A
中的文件夹/path/to/remote
到从服务器Busername@remote_host_B
的文件夹下:/path/to/remote/directory
应该在服务器A上运行 scp 命令:
scp -r /path/to/remote username@remote_host_B:/path/to/remote/directory
如果服务器B使用了非默认的SSH端口,你需要指定端口号,例如:
scp -P <port> -r /path/to/remote username@remote_host_B:/path/to/remote/directory
scp放后台运行:
- 运行 scp 命令,但先不放到后台,例如:
scp file.txt user@remote:/path/to/destination
- 输入密码。
- 输入完密码后,按 Ctrl + Z 暂停进程。
- 使用 bg 命令将任务放到后台运行:
bg
- 使用 disown 命令将任务从当前 shell 断开,防止它在 shell 关闭时被终止:
disown