【问题标题】:installing sshpass on amazon linux AMI based ec2 instance在基于 amazon linux AMI 的 ec2 实例上安装 sshpass
【发布时间】:2014-03-01 09:32:03
【问题描述】:

我计划自动化 aws-rackspace 服务器迁移。我正在关注使用 rsync 进行迁移的官方 rackspace 文档(https://github.com/cloudnull/InstanceSync/blob/master/rsrsyncLive.sh)。我已修改代码以使用 sshpass 在与远程服务器建立 SSH 连接时动态提供登录密码。

sshpass -p "YOUR_PASSWORD" ssh -o StrictHostKeyChecking=no username@IPAddress

但是我在安装 sshpass 包时遇到了麻烦。

Debian based Distros - Installed Successfully
CentOS - Installed Successfully
Redhat - Package not found (yum list available | grep sshpass) 
Amazon Linux -  Package not found (yum list available | grep sshpass) 

我什至尝试了“yum update”,然后尝试了“yum -y install sshpass”,但没有成功。

谢谢,

【问题讨论】:

    标签: linux amazon-web-services ssh yum rackspace-cloud


    【解决方案1】:

    你需要手动下载sshpass的源代码,然后

    Extract it and cd into the directory
    ./configure
    sudo make install
    

    注意:如果你没有找到make,那么你可以运行以下命令来安装make

    sudo yum groupinstall "Development Tools"
    

    【讨论】:

      【解决方案2】:

      我在another stack overflow page 上找到了这个答案,但是当yum install sshpass 返回时它对我有用

      “没有可用的包 sshpass”

      尝试在 AWS 实例上安装时。

      命令:

      yum --enablerepo=epel -y install sshpass
      

      【讨论】:

        【解决方案3】:

        我认为一些细节可能有助于快速完成这项工作。

        这里可以下载 sshpass(搜索最近的更新):http://sourceforge.net/projects/sshpass/files/sshpass/1.05/ 并从页面获取下载的 URL,如下所示

        $ wget http://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz/download # on your amazon instance, to download using command line / terminal; this will get you a file named "download"
        
        $ mv download sshpass-1.05.tar.gz # note this is the name as in the URL above
        
        $ gunzip sshpass-1.05.tar.gz
        $ tar xvf sshpass-1.05.tar
        
        $ cd sshpass-1.05
        
        $ sudo yum groupinstall "Development Tools" # in case configure & make (next 2 commands) does not work, else dont run this command
        
        $ sudo ./configure
        
        $ sudo make install
        
        $ sudo -s
        # which sshpass #sudo -s and check if sshpass is in the path; on amazon RHEL, for me the root did not have /usr/local/bin in its path; so you may want to set the path appropriately (echo $PATH), or copy sshpass to one of the $PATH directories
        

        【讨论】:

        • 对已接受答案的有用补充。但是,我要指出 ./configure 不需要 sudo。您可能还应该先运行不带 sudo 的 make 进行编译,完成后运行 sudo make install。
        【解决方案4】:

        在 Amazon Linux 2 上我这样做

        sudo amazon-linux-extras install epel -y
        sudo yum-config-manager --enable epel
        sudo yum install sshpass
        

        【讨论】:

          【解决方案5】:
          1. Downloadrpm 文件
          2. #苏-
          3. # rpm -ivh [传递到您的 rpm 文件]

          【讨论】:

            【解决方案6】:

            在 Ansible Master (Amazon Linux) 之前:

            linux1 | UNREACHABLE! => {
                "changed": false,
                "msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n",
                "unreachable": true
            }
            

            执行以下操作后:

            sudo yum --enablerepo=epel -y install sshpass
            

            Ping 成功了!

            linux1 | SUCCESS => {
                "changed": false,
                "ping": "pong"
            }
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2012-03-01
              • 1970-01-01
              • 1970-01-01
              • 2018-09-09
              • 2018-05-06
              • 2014-08-05
              • 2022-05-25
              • 2017-09-22
              相关资源
              最近更新 更多