使用 ssh 连接在 2 个不同的服务器中添加 1 个具有 htpasswd 的用户

adding 1 user with htpasswd in 2 different servers using ssh connection

我正在使用 apache camel,我想在两个不同的版本中添加一个用户 servers.And 我想测试 ssh.redundancy=true.This 是否是我的代码:

                   <simple ${headers.op} == 1</simple>
                   <doTry id="try-cmd-httpd">
                       <setBody id="httpd.cmd.htpasswd">
                           <simple>htpasswd -b /etc/httpd/passwords ${header.login} ${header.passwd} {{httpd.io_redir}}</simple>
                       </setBody>
                      **<to id="to_exec_htpaswd" uri="ssh://{{ssh.user}}:{{ssh.passwd}}@{{ssh.host}}:{{ssh.port}}"/>**
                         <log id="htpasswdResp_log" message="response: ${body}"/>
                
                         **<to id="to_exec_htpaswd2" uri="ssh://{{ssh.user}}:{{ssh.passwd}}@{{ssh.host2}}:{{ssh.port}}"/>**
                         <log id="htpasswdResp_log2" message="response: ${body}"/> ```

我发现 solution.Just 为参数 ssh.redundancy 添加了一个选项并第二次调用。

                            <when id="redundancytrue">
                                <simple>{{ssh.redundancy}} == "true"</simple>
                                <setBody id="httpd.cmd.htpasswd">
                                    <simple>htpasswd -b /etc/httpd/passwords ${header.login} ${header.passwd} {{httpd.io_redir}}</simple>
                                </setBody>
                                <to id="to_exec_htpaswd2" uri="ssh://{{ssh.user}}:{{ssh.passwd}}@{{ssh.host2}}:{{ssh.port}}"/>
                              </when>
                        </choice>```