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文件中。  

  • 相关阅读:
    P4068 [SDOI2016]数字配对
    牛客挑战赛43 集合操作
    codefoces 1393D Rarity and New Dress
    codefoces 1400E Clear the Multiset
    [TJOI2017]城市 树形dp
    codefoces 1407E Egor in the Republic of Dagestan
    codefoces 1407D Discrete Centrifugal Jumps
    java保留两位小数(四舍五入和非四舍五入)
    JAVA在命令行进行输入输出重定向(JAVA SentinelValue)
    分治法(排列问题)
  • 原文地址:https://www.cnblogs.com/mengxiaotian/p/5198870.html
Copyright © 2011-2022 走看看