zoukankan      html  css  js  c++  java
  • rex ssh公钥认证

    认证:
    
    前面的示例中我们演示了怎么通过用户名密码登陆,其实也可以用秘钥认证
    
    使用密钥认证只需要在Rexfile里定义你的公钥和私钥既即可:
    
    user "my-user";
    private_key "/home/user/.ssh/id_rsa";  ##私钥
    public_key "/home/user/.ssh/id_rsa.pub"; ##公钥
    key_auth;
    
    
    [root@node01 my-first-rex-project]# cat Rexfile
    use Rex -feature => ['1.0'];
    
    user "root";
    private_key "/root/.ssh/id_rsa";  ##私钥
    public_key "/root/.ssh/id_rsa.pub"; ##公钥
    key_auth;
    
    group myservers => "192.168.137.3";
    
    desc "Get the uptime of all servers";
    task "uptime", group => "myservers", sub {
       my $output = run "uptime";
       say $output;
    };
    
    desc "Start Mysql Service";
    task "start_mysql", group => "myservers", sub {
        service "mysql" => "start";
    };
    [root@node01 my-first-rex-project]# rex uptime
    [2017-04-29 10:16:24] INFO - Running task uptime on 192.168.137.3
     01:18:43 up 21:46,  1 user,  load average: 0.00, 0.00, 0.00
    [2017-04-29 10:16:35] INFO - All tasks successful on all hosts
    [root@node01 my-first-rex-project]# 
    

  • 相关阅读:
    计算几何
    差三角
    约瑟夫
    字符编码
    河南省赛之Substring
    移动字母
    抽屉原理
    不要为了完成代码而写代码
    分布式文件系统优化
    降低代码的复杂度
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349747.html
Copyright © 2011-2022 走看看