当前位置: 首页 > news >正文

成都和奇乐网站建设公司怎么样2023年8月疫情严重吗

成都和奇乐网站建设公司怎么样,2023年8月疫情严重吗,电销系统外呼软件,家具设计网站大全Linux基础命令-seq打印数字序列 前言 有时候不可避免的需要将文件复制到另外一台服务器上,那么这时就可以使用scp命令远程拷贝文件,scp命令是基于SSH协议,在复制的过程中数据都是加密过的,会比明文传输更为安全。 一.命令介绍 …

Linux基础命令-seq打印数字序列

前言

有时候不可避免的需要将文件复制到另外一台服务器上,那么这时就可以使用scp命令远程拷贝文件,scp命令是基于SSH协议,在复制的过程中数据都是加密过的,会比明文传输更为安全。

一.命令介绍

依旧惯例,先到scp的帮助文档中查看命令的概述

NAMEscp — secure copy (remote file copy program)
DESCRIPTIONscp copies files between hosts on a network.  It uses ssh(1) for data transfer, and uses the sameauthentication and provides the same security as ssh(1).  scp will ask for passwords or passphrases ifthey are needed for authentication.File names may contain a user and host specification to indicate that the file is to be copied to/fromthat host.  Local file names can be made explicit using absolute or relative pathnames to avoid scptreating file names containing ‘:’ as host specifiers.  Copies between two remote hosts are also per‐mitted.

scp(secure copy)命令,主要功能是用来远程拷贝文件,可以在多台Linux系统之间复制文件或目录,有些类似于cp命令的功能,但复制的范围是网络上的另一台主机。

二. 命令语法

scp命令语法格式:scp 参数 文件

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

三. 常用参数

文档中一共有这么多的参数,总结一些比较常用的;

     -1      Forces scp to use protocol 1.-2      Forces scp to use protocol 2.-3      Copies between two remote hosts are transferred through the local host.  Without this optionthe data is copied directly between the two remote hosts.  Note that this option disables theprogress meter.-4      Forces scp to use IPv4 addresses only.-6      Forces scp to use IPv6 addresses only.-B      Selects batch mode (prevents asking for passwords or passphrases).-C      Compression enable.  Passes the -C flag to ssh(1) to enable compression.-c cipherSelects the cipher to use for encrypting the data transfer.  This option is directly passed tossh(1).-F ssh_configSpecifies an alternative per-user configuration file for ssh.  This option is directly passedto ssh(1).-i identity_fileSelects the file from which the identity (private key) for public key authentication is read.This option is directly passed to ssh(1).-l limitLimits the used bandwidth, specified in Kbit/s.-o ssh_optionCan be used to pass options to ssh in the format used in ssh_config(5).  This is useful forspecifying options for which there is no separate scp command-line flag.  For full details ofthe options listed below, and their possible values, see ssh_config(5).AddressFamilyBatchModeBindAddressCanonicalDomainsCanonicalizeFallbackLocalCanonicalizeHostnameCanonicalizeMaxDotsCanonicalizePermittedCNAMEsCertificateFileChallengeResponseAuthenticationCheckHostIPCipherCiphersCompressionCompressionLevelConnectionAttemptsConnectTimeoutControlMaster-2      Forces scp to use protocol 2.-3      Copies between two remote hosts are transferred through the local host.  Without this optionthe data is copied directly between the two remote hosts.  Note that this option disables theprogress meter.-4      Forces scp to use IPv4 addresses only.-6      Forces scp to use IPv6 addresses only.-B      Selects batch mode (prevents asking for passwords or passphrases).-C      Compression enable.  Passes the -C flag to ssh(1) to enable compression.-c cipherSelects the cipher to use for encrypting the data transfer.  This option is directly passed tossh(1).-F ssh_configSpecifies an alternative per-user configuration file for ssh.  This option is directly passedto ssh(1).-i identity_fileSelects the file from which the identity (private key) for public key authentication is read.This option is directly passed to ssh(1).-l limitLimits the used bandwidth, specified in Kbit/s.-o ssh_optionCan be used to pass options to ssh in the format used in ssh_config(5).  This is useful forspecifying options for which there is no separate scp command-line flag.  For full details ofthe options listed below, and their possible values, see ssh_config(5).

常用参数:

命令选项含义
-1使用ssh协议版本1
-2使用ssh协议版本2
-4使用ipv4
6使用ipv6
-B以批处理模式运行
-C使用压缩
-F指定ssh配置文件
-l指定带宽限制
-o指定使用的ssh选项
-P指定远程主机的端口号
-p保留文件的修改时间,访问时间和权限模式
-q不显示复制进度
-r以递归的方式进行复制

四. 参考实例

4.1 从本地远程复制到另一台服务器

4.1.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

案例演示:

scp /usr/local/nginx/conf/nginx.conf root@192.168.45.128:/usr/local/nginx/confscp /usr/local/nginx/conf/nginx.conf root@192.168.45.128:/usr/local/nginx/conf/nginx.conf.backupscp /usr/local/nginx/conf/nginx.conf 192.168.45.128:/usr/local/nginx/confscp /usr/local/nginx/conf/nginx.conf 192.168.45.128:/usr/local/nginx/conf.backup

4.1.2 拷贝目录到远程服务器

命令格式: 拷贝目录

第一种方式:指定用户名,将目录远程拷贝到另外一台服务器的指定目录下,需要使用-r参数表示递归操作,命令执行后再输入密码
scp -r local_folder remote_username@remote_ip:remote_folder

第二种方式:不指定用户名,将目录远程拷贝到另外一台服务器的指定目录下,需要使用-r参数表示递归操作,命令执行后再输入密码
scp -r local_folder remote_ip:remote_folder

案例演示:

scp -r /tmp/ root@192.168.45.128:/
scp -r /tmp/ 192.168.45.128:/

4.2 从远程复制到本地服务器

从 远程复制到本地,只要将从本地复制到远程的命令的后2个参数 调换顺序即可,一起来看下。

4.2.1 远程服务器的文件拷贝到本地

第一种方式:指定远程用户名@指定IP:要复制的文件到./,这里./表示将远程服务器上的文件拷贝到本地服务器的当前路径。
scp remote_username@remote_ip:remote_file ./

第二种方式:指定远程用户名@指定IP:要复制的文件到本地服务器指定用户名,指定目录等
scp remote_username@remote_ip:remote_file local_username@local_ip:local_folder

案例演示:

scp root@192.168.45.128:/usr/local/nginx/conf/nginx.conf 
/usr/local/conf/
scp -r root@192.168.45.128:/usr/local/nginx/ root@192.168.45.166:/usr/local/

当然也可以拷贝目录,方法还是一样在前面加-r参数,这里就不再演示。

除了可以选择IP来拷贝文件,还可以使用主机名进行拷贝,前提需要先将hostname做hosts映射。

cat /etc/hosts
192.168.45.166 localhost166
192.168.45.128 localhost128scp -r root@localhost128:/usr/local/nginx/ root@localhost166:/usr/local

总结

scp命令也是经常会需要用到的,只需要了解从本地到远程,或从远程到本地的是如何使用即可,若觉得以上内容还行,可以点赞支持一下!
在这里插入图片描述

http://www.dt0577.cn/news/3733.html

相关文章:

  • wordpress修改省略图seo引擎优化外包公司
  • 秦皇岛一日游必去景点seo顾问服务公司站长
  • 微信公众平台官网入口seo排名的影响因素有哪些
  • 日照网络公司seo的培训网站哪里好
  • 网站做进一步优化免费发布广告信息平台
  • 扬州专注企业网站建设武汉seo推广
  • 网页设计教程花之语如何优化企业网站
  • 河北网站备案手机号码短信核验查询网站注册信息
  • 哈尔滨专门做网站简短的营销软文范文
  • 亚马逊产品开发流程8个步骤南昌seo专业团队
  • 滨海哪家专业做网站怎么做网站免费的
  • 阿里云上能建设自己的企业网站竞价排名的服务模式是
  • 公司微信网站制作搜外
  • 做苗木网站哪个公司好搜索引擎调词平台多少钱
  • 郑州网站建设郑州网站建设地推接单平台找推网
  • 怎么做盈利的网站搜狗网站收录入口
  • 网站的维护和更新常德seo
  • 医疗电子科技网站建设免费crm系统手机版
  • 单产品网站建设推广是做什么工作的
  • 网站建设信息稿长春seo顾问
  • 淘客网站怎么做济南网站建设老威
  • 吉林做网站优化怎么做微信小程序
  • 做响应式网站价格网页查询
  • 网页游戏在线网站推广seo招聘
  • 网站弹幕代码网红营销
  • 广东做网站优化公司报价微信管理系统软件
  • py怎么做网站北京网站优化
  • 网站域名注册申请东莞网站推广及优化
  • 网站文件夹没有权限设置windows优化大师怎么用
  • 有什么好的网站可以接单子做seo搜索优化招聘