码迷,mamicode.com
首页 > 系统相关 > 详细

linux文件操作

时间:2018-08-19 23:26:59      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:用户   格式   name   网络   拷贝   lin   机器   tin   inux   

scp copies files between hosts on a network.  It uses ssh(1) for data transfer, and uses the same authentication and provides 
the same securityas ssh(1).

scp will ask for passwords or passphrases if they are needed for authentication.
File names may contain a user and host specification to indicate that the file is to be copied to/from that host.

Local file names can be made explicit using absolute or relative pathnames to avoid scp treating
file names containing `:‘ as host specifiers. Copies between two remote hosts are also permitted.

个人解读:

(1)scp通过网络在多个主机间拷贝文件(不一定是远端拷贝到本地)

(2)使用ssh工具的1版本协议做数据传输

(3)要账号和密码认证

(4)包含:就算远端机器

 

常用例子:

(1)远程拷贝到本地

   scp remote@www.abc.com:/usr/local/sin.sh /home/administrator
   remote                       通过remote用户登录到远程服务器(也可以使用其他拥有同等权限的用户)
   www.abc.com              远程服务器的域名(当然也可以使用该服务器ip地址)
   /usr/local/sin.sh           欲复制到本机的位于远程服务器上的文件
   /home/administrator  将远程文件复制到本地的绝对路径

(2)本地拷贝到服务器

  scp /home/administrator/news.txt root@192.168.6.129:/etc/squid
  /home/administrator/      本地文件的绝对路径
  news.txt                          要复制到服务器上的本地文件
  root                                 通过root用户登录到远程服务器(也可以使用其他拥有同等权限的用户)
  192.168.6.129                远程服务器的ip地址(也可以使用域名或机器名)
  /etc/squid                       将本地文件复制到位于远程服务器上的路径 

 

备注:

  1.如果远程服务器防火墙有特殊限制,scp便要走特殊端口,具体用什么端口视情况而定,命令格式如下:
  #scp -p 4588 remote@www.abc.com:/usr/local/sin.sh /home/administrator
  2.使用scp要注意所使用的用户是否具有可读取远程服务器相应文件的权限。

linux文件操作

标签:用户   格式   name   网络   拷贝   lin   机器   tin   inux   

原文地址:https://www.cnblogs.com/chendeming/p/8166225.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!