scp命令用于Windows和Linux之间复制文件

20 篇文章 2 订阅
11 篇文章 0 订阅

简述

Linux scp 命令用于 Linux 之间复制文件和目录。
scp 是 secure copy 的缩写, scp 是 linux 系统下基于 ssh 登陆进行安全的远程文件拷贝命令。
scp 是加密的,rcp 是不加密的,scp 是 rcp 的加强版。

Windows和Linux之间复制文件

Windows本身不支持ssh协议,因此要互传文件,需在Windows系统上安装ssh for Windows的软件
如winsshd,可以使Windows系统支持ssh协议;或者用Windows自带的openssh
流程:右键左下角“开始”->“设置”->“应用”->“可选功能”->进行操作
如下图:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

使用

Windows下是在shift+鼠标右键进行powershell下键入命令
linux是在terminal终端下键入命令:Ctrl+Alt+T

scp [可选参数] file_source file_target 

基本参数:
-f:表示复制文件
-r:表示递归文件夹
参数可参考:链接: https://www.runoob.com/linux/linux-comm-scp.html

示例

从本地复制到远程
复制文件
本地文件->远程文件夹
scp local_file remote_username@remote_ip:remote_folder 
本地文件->远程文件
scp local_file remote_username@remote_ip:remote_file 

输入完,敲回车,需输入远程密码

复制文件夹
本地文件夹->远程文件夹
scp -r local_folder remote_username@remote_ip:remote_folder 

输入完,敲回车,需输入远程密码

从远程复制到本地
复制文件
远程文件->本地文件
scp  remote_username@remote_ip:remote_file local_file

输入完,敲回车,需输入远程密码

复制文件夹
远程文件夹->本地文件夹
scp -r  remote_username@remote_ip:remote_folder local_folder

输入完,敲回车,需输入远程密码

在Linux下(从Linux复制到Windows)
复制文件
scp /home/hh/Desktop/test.txt hh@192.168.123.123:/C:/Users/hh/Desktop/newFolder
或
scp /home/hh/Desktop/test.txt hh@192.168.123.123:/C:/Users/hh/Desktop/newFolder/test.txt

输入完,敲回车,需输入远程密码
hh为Windows用户名,192.168.123.123为Windows的ip,/C:/Users/hh/Desktop/newFolder(/C:/Users/hh/Desktop/newFolder/test.txt)为想要将文件复制到Windows的哪个文件夹(文件)

复制文件夹
本地文件夹->远程文件夹
scp -r /home/hh/Desktop/ hh@192.168.123.123:/C:/Users/hh/Desktop/newFolder

输入完,敲回车,需输入远程密码

在Windows下(从Windows复制到Linux)
复制文件
scp C:/Users/hh/Desktop/newFolder/test.txt hh@192.168.123.123:/home/hh/Desktop/
或
scp C:/Users/hh/Desktop/newFolder/test.txt hh@192.168.123.123:/home/hh/Desktop/test.txt

hh为Linux用户名,192.168.123.123为Linux的ip,/home/hh/Desktop(/home/hh/Desktop/test.txt)为想要将文件复制到Linux的哪个文件夹(文件)

复制文件夹
scp -r C:/Users/hh/Desktop/newFolder hh@192.168.123.123:/home/hh/Desktop
在Linux下(从Windows复制到Linux)
复制文件
scp hh@192.168.123.123:C:/Users/hh/Desktop/newFolder/test.txt 
/home/hh/Desktop/
或
scp hh@192.168.123.123:C:/Users/hh/Desktop/newFolder/test.txt 
/home/hh/Desktop/test.txt

hh为Windows用户名,192.168.123.123为Windows的ip,/home/hh/Desktop(/home/hh/Desktop/test.txt)为想要将文件复制到Linux的哪个文件夹(文件)

复制文件夹
scp -r hh@192.168.123.123:C:/Users/hh/Desktop/newFolder/
/home/hh/Desktop/
在Windows下(从Linux复制到Windows)
复制文件
scp hh@192.168.123.123:/home/hh/Desktop/test.txt
C:/Users/hh/Desktop/newFolder/
或
scp hh@192.168.123.123:/home/hh/Desktop/test.txt
C:/Users/hh/Desktop/newFolder/test.txt 

hh为Linux用户名,192.168.123.123为Linux的ip,C:/Users/hh/Desktop/newFolder(C:/Users/hh/Desktop/newFolder/test.txt )为想要将文件复制到Windows的哪个文件夹(文件)

复制文件夹
scp hh@192.168.123.123:/home/hh/Desktop/
C:/Users/hh/Desktop/newFolder/
  • 4
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FreeLikeTheWind.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值