使用scp命令在不同服务器上传输文件

场景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放后台运行:

  1. 运行 scp 命令,但先不放到后台,例如:
scp file.txt user@remote:/path/to/destination
  1. 输入密码。
  2. 输入完密码后,按 Ctrl + Z 暂停进程。
  3. 使用 bg 命令将任务放到后台运行:
bg
  1. 使用 disown 命令将任务从当前 shell 断开,防止它在 shell 关闭时被终止:
disown
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值