scp使用
阐述
scp是securecopy的简写,scp是linux系统下基于ssh登录进行安全的远程文件拷贝命令。
scp是加密的,rcp是不加密的,scp是rcp的强化版。
Windows和Linux之间复制文件
Windows本身不支持ssh合同,因而要互传文件,需在Windows系统上安装sshforWindows的软件
如winsshdlinux互传文件的软件linux软件工程师,可以使Windows系统支持ssh合同;或则用Windows自带的openssh
流程:右键左下角“开始”->“设置”->“应用”->“可选功能”->进行操作
如右图:
使用
Windows下是在shift+滑鼠右键进行powershell下键入命令
linux是在terminal终端下键入命令:Ctrl+Alt+T
scp [可选参数] file_source file_target
基本参数:
-f:表示复制文件
-r:表示递归文件夹
参数可参考:链接:
示例从本地复制到远程复制文件
本地文件->远程文件夹
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
输入完linux互传文件的软件,敲回车,需输入远程密码
在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用户名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/