简体   繁体   中英

installing sshpass on amazon linux AMI based ec2 instance

I am planning to automate aws-rackspace server migration. I am following the official rackspace documentation( https://github.com/cloudnull/InstanceSync/blob/master/rsrsyncLive.sh ) which uses rsync to migrate. I have modified the code to use sshpass to dynamically provide login password while making an SSH connection to the remote server.

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

But I am facing trouble installing sshpass package.

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) 

I even tried 'yum update' and then 'yum -y install sshpass' but it didn't work.

Thanks,

You need to manually download source code of sshpass ,after that

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

Note :: If you do not find make then you can run following command for installing make

sudo yum groupinstall "Development Tools"

I thought a little bit of details may help to get this done quickly.

This is where sshpass can be downloaded from (search for any recent updates): http://sourceforge.net/projects/sshpass/files/sshpass/1.05/ And from the page get the URL for the download as below

$ 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

I found this answer on another stack overflow page , but it worked for me when yum install sshpass was returning

"No package sshpass available"

when trying to install on an AWS instance.

Command:

yum --enablerepo=epel -y install sshpass
  1. Download rpm file
  2. # su -
  3. # rpm -ivh [pass to your rpm file]

On Ansible Master (Amazon Linux) Before:

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

After exection the following:

sudo yum --enablerepo=epel -y install sshpass

Ping worked!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM