zoukankan      html  css  js  c++  java
  • 使用scp免passwordserver间传递文件

    1. 1.aserver下执行命令  ssh-keygen -t rsa
    2. 2.三个回车
    3. 3.在用户的文件夹下 ~/.ssh/产生两个文件,id_rsa,id_rsa.pub
    4. 4.把aserver下相应的文件复制到bserver 并重命名为 authorized_keys
      1. scp /root/.ssh/id_rsa.pub root@10.0.1.22:/root/.ssh/authorized_keys


    5. scp 命令:
    6. scp命令说明

      scp – 安全复制 (远程文件复制工具)

      语法:

      scp [-1245BCpqrv] [-c cipher] [F ssh_config] [-I identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:] file1 […] [[suer@]host2:]file2

      说明:

      Scp在主机间拷贝文件。他使用 ssh(1)作为传输数据。并且用相同认证和安全性。 scp将在认证中请求输入password全部的文件可能须要server和用户的特别描写叙述来指明文件将被复制到/从某台server。

      两个远程登录的server间的文件复制是同意的。

      选项:

      • -1 强制scp 用协议1
      • -2 强制scp 用协议2
      • -4 强制scp用IPV4的网址
      • -6 强制scp用IPV6的网址
      • -B 选择批处理模式(防止输入password)
      • -C 同意压缩。 标注-C到ssh(1)来同意压缩
      • -c cipher 选择cipher来加密传输数据。这个选项直接传递到ssh(1)
      • -F ssh_config 设定一个可变动的用户配置给ssh.这个选项直接会被传递到ssh(1)
      • -i identity_file 选择被RSA认证读取私有password的文件。这个选项能够直接被传递到ssh(1)
      • -l limit 限制传输带宽。也就是速度 用Kbit/s的速度
      • -o ssh_option 能够把ssh_config中的配置格式传到ssh中。这样的模式对于说明没有独立的scp文件里断符的scp非常有帮助。

      • -P port 指定连接远程连接端口。注意这个选项须要写成大写的模式。由于-p已经早保留了次数和模式
      • -S program 指定一个加密程序。这个程序必须可读全部ssh(1)的选项。

      • -p 指定改动次数,连接次数,还有对于原文件的模式
      • -q 把进度參数关掉
      • -r 递归的复制整个文件夹
      • -S program 指定一个加密程序。这个程序必须可读全部ssh(1)的选项。

      • -V 冗余模式。

        让 scp 和 ssh(1) 打印他们的排错信息, 这个在排错连接,认证,和配置中非常实用。

      样例:
    7. 拷贝本机文件夹到远程文件夹
    8.  scp -r /home/test/ root@10.0.1.22:/root/

    9. 拷贝本机单个文件到远程

    10. scp /home/test/test.txt root@10.0.1.22:/root/

    11. 远程文件下载到本地

    12. scp -r root@10.0.1.22:/root/ /home/test/new/


  • 相关阅读:
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
    Data Structure and Algorithm
  • 原文地址:https://www.cnblogs.com/llguanli/p/8681117.html
Copyright © 2011-2022 走看看