Linux与Mac系统用SCP互传文件

    xiaoxiao2021-03-25  95

    linux系统之间,或者linux与mac之间可以使用scp命令互传文件(即上传或下载)。下面就以实例介绍一下这个命令。

    使用scp需要两台服务器都开启ssh服务,具体详见Linux 开启ssh服务

     基本语法

    scp用法如下

    基本格式: scp [可选参数] file_source file_target

    传输文件到其他服务器 scp local_file remote_username@remote_ip:remote_file

    从其他服务器下载文件 scp remote_username@remote_ip:remote_file local_file

     实例使用

    如将本地文件node.md传到局域网内IP为192.168.0.162的Linux服务器上,命令如下:

    scp node.md root@192.168.0.162:/home/wthfeng/

    就可将node.md文件传到162服务器的/home/wthfeng目录。如需传输文件夹,可加 -r选项。

    将js文件夹传到远程 scp -r js/ root@192.168.0.162:/home/wthfeng/

    再将远程的js文件夹下载下来,重命名为js2

    scp -r wangtonghe@192.168.0.162:/home/wangtonghe/js js2/

    OK,基本使用就是这样,scp用法如下:

    usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2

    如上可知,指定端口号参数为-P ,如ssh默认端口22禁用,可使用此参数重新指定。

    转载请注明原文地址: https://ju.6miu.com/read-20750.html

    最新回复(0)