zoukankan      html  css  js  c++  java
  • scp采用无密码在两台linux服务器之间传输数据

    一、root用户:

    1. 在主机A上执行如下命令来生成配对密钥: 
    ssh-keygen -t rsa 
    按照提示操作,注意,不要输入passphrase。提示信息如下 
    Generating public/private rsa key pair. 
    Enter file in which to save the key (/root/.ssh/id_rsa):  
    Enter passphrase (empty for no passphrase):  
    Enter same passphrase again:  
    Your identification has been saved in /root/.ssh/id_rsa. 
    Your public key has been saved in /root/.ssh/id_rsa.pub. 
    The key fingerprint is: 
    ff:8e:85:68:85:94:7c:2c:46:b1:e5:2d:41:5c:e8:9b  root@localhost.domain 

    2. 将 .ssh 目录中的 id_rsa.pub 文件复制到 主机B 的 ~/.ssh/ 目录中,并改名为  authorized_keys。 
    scp .ssh/id_rsa.pub 192.168.10.2:/root/.ssh/authorized_keys 

    二、其他用户

    A 机器上

    A server上
    第一步, 进入/home/linuxidc  cd /home/linuxidc  (因为我们使用的是linuxidc用户,如果使用了其他用户,就需要进去其他用户的目录, 比如 cd /home/weblogic)
    第二部, 创建.ssh目录, mkdir .ssh
    第三部, 进入.ssh目录,cd .ssh
    第四部, 执行 ssh-keygen -b 1024 -t rsa

    B server上
    第一步, 进入/home/linuxidc  cd /home/linuxidc  (因为我们使用的是linuxidc用户,如果使用了其他用户,就需要进去其他用户的目录, 比如 cd /home/weblogic)
    第二部, 创建.ssh目录, mkdir .ssh
    第三部, 进入.ssh目录,cd .ssh
    第四部, 创建新文件authorized_keys,  touch authorized_keys

    A server上
    第五步, 执行scp -p .ssh/id_rsa.pub linuxidc@xxxx.238:/home/linuxidc/.ssh/authorized_keys/authorized_keys
            将生成的id_rsa.pub放到B server上的授权key文件中。  

  • 相关阅读:
    eclipse里报:An internal error occurred during: "Building workspace". Java heap space
    bootstrap字体图标不显示的问题解决
    @PathVariable和@RequestParam的区别
    String Date Calendar之间的转换
    java多种方式解析json字符串
    PHP中empty、isset和is_null的使用区别
    C中atoi和strcpy的自定义实现
    【2014-08-23】Beyong Coding
    算法时间复杂度求解法【详细过程说明】
    #查找算法#【2】二叉排序树
  • 原文地址:https://www.cnblogs.com/mengxiaotian/p/5198870.html
Copyright © 2011-2022 走看看