linux系统scp命令详解?
scp是有Security的文件copy,基于ssh登录。操作起来比较方便,比如要把当前一个文件copy到远程另外一台主机上
命令格式:
scp -r local_file remote_username@remote_ip:remote_folder
或者
scp -r local_file remote_username@hostname:remote_folder (这里使用hostname,是因为提前配置了hosts映射)
或者
scp -r local_file remote_username@remote_ip:remote_file
或者
scp -r local_file remote_ip:remote_folder
或者
scp -r local_file remote_ip:remote_file
注:-r 是递归的意思,相当于把文件目录包括里面的内容都递归复制到目标机器
如果没有配置ssh无密登录会在输入复制命令回车后要去输入远程机器的用户登录密码
从远程机器复制到本地当前操作的机器(跟上面操作反过来)remote_ip同样可以换成hostname,条件也是提前配置了hosts映射
如:scp -r remote_username@remote_ip:remote_file ./
注:./的意思是当前所在目录,即正在操作的当前机器目录位置,也可以写成具体路径:
scp -r remote_username@remote_ip:remote_file local_username@hostname:local_folder
linux下scp命令用法?
Linux scp命令用于Linux之间复制文件和目录:
scp 可以在 2个 linux 主机间复制文件;
命令基本格式:
scp [可选参数] file_source file_target
1从 本地 复制到 远程
* 复制文件:
* 命令格式:
scp local_file remote_username@remote_ip:remote_folder
或者
scp local_file remote_username@remote_ip:remote_file
或者
scp local_file remote_ip:remote_folder
或者
scp local_file remote_ip:remote_file
linux中sudo怎么执行scp传文件?
在Linux中,使用sudo执行scp传输文件需要在命令前加上sudo,如下所示:sudo scp /path/to/local/file username@remote:/path/to/remote/directory。
其中,/path/to/local/file是本地文件的路径,username是远程登录的用户名,remote是远程主机的IP地址或域名,/path/to/remote/directory是远程主机存储文件的目录路径。
执行该命令后,会提示输入远程主机的密码,输入密码后即可执行文件传输操作。

