• linux-scp命令及如何设置免密登录


    部署测试环境时经常在两台服务器间copy文件,那么如何设置免密登录?

    场景:源服务器A(如172) -> 目标服务器B(如71)  实现将服务器A的文件copy到服务器B

    实现方式有两种:

    在源服务器A(172)上执行:若两台服务期间已设置免密登录(绿色字体是设置免密登录),那么只需要执行下述红色命令


    首先运行命令 ssh-keygen 根据提示一路回车即可 [yyuser@hlyy .ssh]$ ssh-copy-id chenjl@10.1.1.71 /bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/yyuser/.ssh/id_rsa.pub" /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys chenjl@10.1.1.71's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'chenjl@10.1.1.71'" and check to make sure that only the key(s) you wanted were added. [yyuser@hlyy home]$ ll total 4 -rw-r--r-- 1 root root 0 Sep 2 23:59 a.txt drwx------ 10 yyuser yyuser 4096 Sep 2 17:22 yyuser [yyuser@hlyy home]$ scp -r a.txt chenjl@10.1.1.71:/home/py a.txt 100% 0 0.0KB/s 00:00

    在目标服务器B(71)上执行:若两台服务期间已设置免密登录(绿色字体是设置免密登录),那么只需要执行下述红色命令

    首先执行命令ssh-keygen 根据提示一路回车即可
    [chenjl@ipha-dev71-1 .ssh]$ ssh-copy-id yyuser@10.1.1.172      #将公钥添加到172
    /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/chenjl/.ssh/id_rsa.pub"
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    yyuser@10.1.1.172's password: 
    /home/yyuser/osinfo.sh: line 17: lspci: command not found
    
    Number of key(s) added: 1
    
    Now try logging into the machine, with:   "ssh 'yyuser@10.1.1.172'"
    and check to make sure that only the key(s) you wanted were added.
    
    [chenjl@ipha-dev71-1 .ssh]$ scp yyuser@10.1.1.172:/home/a.txt /home/py
    /home/yyuser/osinfo.sh: line 17: lspci: command not found
    a.txt
  • 相关阅读:
    [BZOJ3751] [NOIP2014] 解方程 (数学)
    [BZOJ4198] [Noi2015] 荷马史诗 (贪心)
    [BZOJ4034] [HAOI2015] T2 (树链剖分)
    [BZOJ1880] [Sdoi2009] Elaxia的路线 (SPFA & 拓扑排序)
    [BZOJ1088] [SCOI2005] 扫雷Mine
    [BZOJ1004] [HNOI2008] Cards (Polya定理)
    [BZOJ1009] [HNOI2008] GT考试 (KMP & dp & 矩阵乘法)
    [BZOJ1503] [NOI2004] 郁闷的出纳员 (treap)
    [BZOJ1059] [ZJOI2007] 矩阵游戏 (二分图匹配)
    BZOJ2626: JZPFAR
  • 原文地址:https://www.cnblogs.com/wang-mengmeng/p/11450620.html
Copyright © 2020-2023  润新知