1. ssh

1.1. 安装

sudo apt install openssh-server # 服务端sudo apt install openssh-client # 客户端

1.2. 使用

# 启动ssh服务
sudo /etc/init.d/ssh start# 设置开机自启动
sudo systemctl enable ssh# 关闭ssh开机自动启动命令
sudo systemctl disable ssh# 单次开启ssh
sudo systemctl start ssh# 单次关闭ssh
sudo systemctl stop ssh

1.3. 远程文件夹挂载到本地

 sshfs administrator@310.20.222.46:~/administrator/ admin

1.4. 远程连接

ssh administrator@310.25.210.17 

1.5. 快捷使用

在~/.ssh/config中添加

Host PCHostName 110.15.126.45User hehe

使用

ssh PC

2. scp

远程文件传送到本地

传文件
scp administrator@310.25.210.17:~/test.txt . 传文件夹
scp -r administrator@310.25.210.17:~/test . 

本地文件传送到远程

传文件
scp test.txt administrator@310.25.210.17:~/传文件夹
scp -r test administrator@310.25.210.17:~/

如果警告中间人攻击则使用下面命令

ssh-keygen -R 310.25.218.17 

3. rsync

3.1. 介绍

rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件。rsync使用所谓的“rsync算法”来使本地和远 程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。rsync支持大多数的类Unix系统,无论是Linux、Solaris还是BSD上都经过了良好的测试。此外,它在windows平台下也有相应的版本,如cwRsync和Sync2NAS等工具。

rsync本来是用于替代rcp的一个工具,目前由rsync.samba.org维护,所以rsync.conf文件的格式类似于samba的主配 置文件;rsync可以通过rsh或ssh使用,也能以daemon模式去运行。

在以daemon方式运行时Rsync server会打开一个873 端口,等待客户端去连接。连接时,rsync server会检查口令是否相符,若通过口令查核,则可以开始进行文件传输。第一次连通完成时,会把整份文件传输一次,以后则就只需进行增量备份。

rsync 具有以下特点

可以镜像保存整个目录树和文件系统;

可以很容易做到保持原来文件的权限、时间、软硬链接等;

无须特殊权限即可安装;

优化的流程,文件传输效率高;

可以使用rsh、ssh等方式来传输文件,当然也可以通过直接的socket连接;

支持匿名传输

3.2. 使用

Usage:
rsync [OPTION]... SRC [SRC]... DEST
rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
rsync [OPTION]... [USER@]HOST:SRC [DEST]
rsync [OPTION]... [USER@]HOST::SRC [DEST]
rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

例如

rsync -av /backup/ -e ssh root@192.168.1.110:/bak
#-a: archive归档模式,表示以递归方式传输文件,并保持所有文件属性,链接等,等于-rlptgoD
#-v: 显示详细信息

3.3. 选项

Options-v, --verbose               increase verbosity--info=FLAGS            fine-grained informational verbosity--debug=FLAGS           fine-grained debug verbosity--msgs2stderr           special output handling for debugging-q, --quiet                 suppress non-error messages--no-motd               suppress daemon-mode MOTD (see manpage caveat)-c, --checksum              skip based on checksum, not mod-time & size-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)--no-OPTION             turn off an implied OPTION (e.g. --no-D)-r, --recursive             recurse into directories-R, --relative              use relative path names--no-implied-dirs       don't send implied dirs with --relative-b, --backup                make backups (see --suffix & --backup-dir)--backup-dir=DIR        make backups into hierarchy based in DIR--suffix=SUFFIX         set backup suffix (default ~ w/o --backup-dir)-u, --update                skip files that are newer on the receiver--inplace               update destination files in-place (SEE MAN PAGE)--append                append data onto shorter files--append-verify         like --append, but with old data in file checksum-d, --dirs                  transfer directories without recursing-l, --links                 copy symlinks as symlinks-L, --copy-links            transform symlink into referent file/dir--copy-unsafe-links     only "unsafe" symlinks are transformed--safe-links            ignore symlinks that point outside the source tree--munge-links           munge symlinks to make them safer (but unusable)-k, --copy-dirlinks         transform symlink to a dir into referent dir-K, --keep-dirlinks         treat symlinked dir on receiver as dir-H, --hard-links            preserve hard links-p, --perms                 preserve permissions-E, --executability         preserve the file's executability--chmod=CHMOD           affect file and/or directory permissions-A, --acls                  preserve ACLs (implies --perms)-X, --xattrs                preserve extended attributes-o, --owner                 preserve owner (super-user only)-g, --group                 preserve group--devices               preserve device files (super-user only)--specials              preserve special files-D                          same as --devices --specials-t, --times                 preserve modification times-O, --omit-dir-times        omit directories from --times-J, --omit-link-times       omit symlinks from --times--super                 receiver attempts super-user activities--fake-super            store/recover privileged attrs using xattrs-S, --sparse                handle sparse files efficiently--preallocate           allocate dest files before writing them-n, --dry-run               perform a trial run with no changes made-W, --whole-file            copy files whole (without delta-xfer algorithm)-x, --one-file-system       don't cross filesystem boundaries-B, --block-size=SIZE       force a fixed checksum block-size-e, --rsh=COMMAND           specify the remote shell to use--rsync-path=PROGRAM    specify the rsync to run on the remote machine--existing              skip creating new files on receiver--ignore-existing       skip updating files that already exist on receiver--remove-source-files   sender removes synchronized files (non-dirs)--del                   an alias for --delete-during--delete                delete extraneous files from destination dirs--delete-before         receiver deletes before transfer, not during--delete-during         receiver deletes during the transfer--delete-delay          find deletions during, delete after--delete-after          receiver deletes after transfer, not during--delete-excluded       also delete excluded files from destination dirs--ignore-missing-args   ignore missing source args without error--delete-missing-args   delete missing source args from destination--ignore-errors         delete even if there are I/O errors--force                 force deletion of directories even if not empty--max-delete=NUM        don't delete more than NUM files--max-size=SIZE         don't transfer any file larger than SIZE--min-size=SIZE         don't transfer any file smaller than SIZE--partial               keep partially transferred files--partial-dir=DIR       put a partially transferred file into DIR--delay-updates         put all updated files into place at transfer's end-m, --prune-empty-dirs      prune empty directory chains from the file-list--numeric-ids           don't map uid/gid values by user/group name--usermap=STRING        custom username mapping--groupmap=STRING       custom groupname mapping--chown=USER:GROUP      simple username/groupname mapping--timeout=SECONDS       set I/O timeout in seconds--contimeout=SECONDS    set daemon connection timeout in seconds-I, --ignore-times          don't skip files that match in size and mod-time-M, --remote-option=OPTION  send OPTION to the remote side only--size-only             skip files that match in size--modify-window=NUM     compare mod-times with reduced accuracy-T, --temp-dir=DIR          create temporary files in directory DIR-y, --fuzzy                 find similar file for basis if no dest file--compare-dest=DIR      also compare destination files relative to DIR--copy-dest=DIR         ... and include copies of unchanged files--link-dest=DIR         hardlink to files in DIR when unchanged-z, --compress              compress file data during the transfer--compress-level=NUM    explicitly set compression level--skip-compress=LIST    skip compressing files with a suffix in LIST-C, --cvs-exclude           auto-ignore files the same way CVS does-f, --filter=RULE           add a file-filtering RULE-F                          same as --filter='dir-merge /.rsync-filter'repeated: --filter='- .rsync-filter'--exclude=PATTERN       exclude files matching PATTERN--exclude-from=FILE     read exclude patterns from FILE--include=PATTERN       don't exclude files matching PATTERN--include-from=FILE     read include patterns from FILE--files-from=FILE       read list of source-file names from FILE-0, --from0                 all *-from/filter files are delimited by 0s-s, --protect-args          no space-splitting; only wildcard special-chars--address=ADDRESS       bind address for outgoing socket to daemon--port=PORT             specify double-colon alternate port number--sockopts=OPTIONS      specify custom TCP options--blocking-io           use blocking I/O for the remote shell--stats                 give some file-transfer stats-8, --8-bit-output          leave high-bit chars unescaped in output-h, --human-readable        output numbers in a human-readable format--progress              show progress during transfer-P                          same as --partial --progress-i, --itemize-changes       output a change-summary for all updates--out-format=FORMAT     output updates using the specified FORMAT--log-file=FILE         log what we're doing to the specified FILE--log-file-format=FMT   log updates using the specified FMT--password-file=FILE    read daemon-access password from FILE--list-only             list the files instead of copying them--bwlimit=RATE          limit socket I/O bandwidth--outbuf=N|L|B          set output buffering to None, Line, or Block--write-batch=FILE      write a batched update to FILE--only-write-batch=FILE like --write-batch but w/o updating destination--read-batch=FILE       read a batched update from FILE--protocol=NUM          force an older protocol version to be used--iconv=CONVERT_SPEC    request charset conversion of filenames--checksum-seed=NUM     set block/file checksum seed (advanced)--noatime               do not alter atime when opening source files-4, --ipv4                  prefer IPv4-6, --ipv6                  prefer IPv6--version               print version number
(-h) --help                  show this help (-h is --help only if used alone)Use "rsync --daemon --help" to see the daemon-mode command-line options.
Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.
See http://rsync.samba.org/ for updates, bug reports, and answers

3.4. 与SCP的区别

rsycn强调的是同步,scp强调的是传输

sync和scp在文件夹均不存在时,执行时间相差不大,但是文件夹存在的情况下差异很大。原因是scp是复制:若mas2文件不存在则新建,若存在则覆盖,若mas2上有而Dashboard主机没有,则不改变。可以理解为scp为“复制”。而rsync则在文件在存在于两主机时,比较两文件是够相同,相同的话,就什么都不做,若存在差异就直接更新。

简单的说rsync只对差异文件做更新。

参考文献

【Linux】Linux 下 rsync 命令使用_RadiantJeral的博客-CSDN博客

rsync与scp对比_lixwjava的专栏-CSDN博客

Linux安装ssh服务并设置开机自启动_来朵小红花的博客-CSDN博客_openssh开机启动

Ubuntu终端远程工具相关推荐

  1. Ubuntu终端远程连接计算机(Linux)

    Ubuntu终端远程连接计算机(Linux) 分类: Linux 2010-07-16 18:13 4725人阅读 评论(0) 收藏 举报 ubuntu远程连接linux终端sshftp服务器 突然发 ...

  2. Ubuntu终端代理工具——proxychains

    安装proxychains sudo apt install proxychains 配置proxychains 打开proxychains配置文件 sudo vim /etc/proxychains ...

  3. ubuntu远程无法连接到服务器配置,解决ubuntu无法远程连接

    在装Ubantu的时候可能有的小伙伴忽略了一点,忘记了在一个地方打一下空格,导致后面无法远程连接. 如果能在这里打上对勾就可以不用后面的操作了. 首先要切换到root账号 sudo passwd ro ...

  4. Ubuntu 远程控制(使用自带远程工具)

    本文主要是讲解如果理由VNC实现Windows远程访问Ubuntu 18.04,其实网上有很多类似教程,但是很多需要安装第三方桌面(xfce桌面等等),而且很多人不太喜欢安装第三方桌面,很多人像笔者一 ...

  5. VNC实现Windows远程访问Ubuntu 16.04(无需安装第三方桌面,直接使用自带远程工具)----本人亲测可用

    原文地址::VNC实现Windows远程访问Ubuntu 16.04(无需安装第三方桌面,直接使用自带远程工具)-蒲公英云 相关文章 1.VNC实现Windows远程访问Ubuntu 16.04(无需 ...

  6. 用secureCRT操作ubuntu终端

    用secureCRT操作ubuntu终端 ubuntu下先安装ssh windows下win+R再输入ubuntu的ip地址   ubuntu 检测端口号的命令 netstat -antp   下载到 ...

  7. 历经一周时间终于把买前生产力买后爱奇艺的iPad变成了事捷功倍的远程工具

    前言:某大学生某天终于有了一个iPad.总有人说iPad是买前生产力,买后爱奇艺,这位大学生总还不信,直到不久前这位大学生发现好像iPad对他的作用就是看看视频真的沦为了一个爱奇艺工具了.于是这位大学 ...

  8. ubuntu 终端常用命令

    http://jewelseeker.blog.163.com/blog/static/5802709320094191015899/?fromdm&fromSearch&isFrom ...

  9. ubuntu终端显示乱码的解决

    ubuntu终端显示乱码的解决 背景 在ubuntu终端,用diff命令比较两个源文件时,发现输出乱码,如下图所示: 原因 Ubuntu默认编码是UTF-8,可以用locale命令查看,在我电脑上查看 ...

最新文章

  1. 受用一生的高效 PyCharm 使用技巧(二)pycharm 指定参数运行文件
  2. 马斯克晒特斯拉Autopilot疯狂驾驶模式,称还要开发“极速惊魂”模式
  3. 全新目标检测范式SparseR-CNN,超详细实战教学(附数据集)
  4. Mac 配置支持 opengl 的 opencv 4.2
  5. linux7.3怎么修改时区,CentOS7校准核对服务器时区和手动修改时间
  6. mysql如何获取当前时间
  7. shop--10.商品--商品添加(前端)及问题的解决
  8. 【javascript】浮点数运算问题分析及解决方法
  9. 开启本地git权限_Git入门使用和常见操作
  10. 说说Thread的interrupt()
  11. linux,内核(kernel)对AD9371配置流程。
  12. 计算机游戏优化,Win10电脑玩游戏优化方法!必须关闭这几个设置,效果提升巨大...
  13. 服务器虚拟机怎么安装win7系统教程,虚拟机怎么安装win7系统 虚拟机安装win7系统教程...
  14. DS12C887实时时钟
  15. 记一个typeorm问题 Main alise is not set
  16. TensorFlow-similarity 学习笔记13
  17. 百度飞桨,让AI落地有解!
  18. 移动开发者大会第一日观感
  19. 分享一个好用的CSS布局
  20. 后端工程师之路(4)GIT工具的使用与介绍

热门文章

  1. oracle 查询重复数据并且删除, 只保留一条数据
  2. vs code vue模板创建
  3. PostgreSQL运维实战精讲之“postgresql源码安装”
  4. Socket中的异常和参数设置
  5. Flex Air程序打包成独立的exe安装文件
  6. 如何在linux下解压缩rar格式的文件压缩包
  7. 浅谈企业IT应用的访问方式之:乱想
  8. gatsby_将您的GraphCMS数据导入Gatsby
  9. php文件夹列表,php获取文件夹下面的文件列表和文件夹列表
  10. 【教你赚钱】独立开发者荒野求生之道