美文网首页
scp命令使用总结

scp命令使用总结

作者: Oceans言欢 | 来源:发表于2019-07-17 12:52 被阅读0次

    简介

    scp是secure copy的缩写,Linux下进行远程拷贝文件的命令。
    scp传输是加密的。

    命令格式

    scp [options] [原路径] [目标路径]
    

    使用

    ps:指定了远程主机的用户名后 命令执行完需要输入密码; 如果没有指定用户名 命令执行完后需要输入用户名和密码。48.89.189.137为测试ip,瞎写的······

    从远程拷贝文件到本地

    scp remote_username@remote_ip: remote_file_location  local_location
    

    说明:

    • remote_username 远程主机的用户名
    • remote_ip 远程主机IP
    • remote_file_location 要拷贝的远程文件的路径
    • local_location 保存远程文件的本地路径

    实例:

    scp root@48.89.189.137:/root/deploy.sh ./  //拷贝远程主机的deploy.sh 文件到本地当前目录下
    

    从远程拷贝目录到本地

    scp -r remote_username@remote_ip: remote_folder_location  local_location
    

    说明:

    • -r 递归复制整个目录
    • remote_folder_location 要拷贝的远程目录的路径

    实例:

    scp -r root@48.89.189.137:/root/code ./   // 拷贝远程主机的code目录 到本地当前目录下
    

    上传本地文件到远程指定目录下

    scp locat_file_location remote_username@remote_ip: remote_file_location
    

    实例:

    scp ./scp_test/ddd.txt  root@48.89.189.137:/root/
    

    上传本地目录到远程指定目录下

    scp -r locat_folder_location remote_username@remote_ip: remote_folder_location
    

    实例:

    scp -r ./scp_test/  root@48.89.189.137:/root/
    

    相关文章

      网友评论

          本文标题:scp命令使用总结

          本文链接:https://www.haomeiwen.com/subject/yjdqlctx.html