Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sshpass: command not found error

I am trying to automate the file transfer or FTP from one server to the other.

#!/bin/bash
### In this model, the same filename is processed on each run.
### A timestamp is added to the result file and data file is copied to the archive or error folder with a timestamp after processing.

# Set current directory
cd `dirname "$0"`

# Set the environment variables
. ./Environment.sh $0

#######################################################################################################
# 
#######################################################################################################


FILE=/hcm/Inbound/file.csv

sshpass -p 'xyz' sftp -oBatchMode=no -b - -oStrictHostKeyChecking=no [email protected] <<_EOF_

cd /upload/

put $FILE

_EOF_

# Exit
exit $?

When I am executing this shell script I am getting the following error in putty :

 -bash: sshpass: command not found

I tried using the ssh passwordless method by ssh-keygen -t dsa and other steps but I cannot access putty of the second server due to which I am not being able to execute the next steps.

Kindly help

like image 223
sreekem bose Avatar asked Jun 30 '16 17:06

sreekem bose


People also ask

What is Sshpass command?

What is sshpass? The sshpass utility is designed to run SSH using the keyboard-interactive password authentication mode, but in a non-interactive way. SSH uses direct TTY access to ensure that the password is indeed issued by an interactive keyboard user.

How install Sshpass rpm Linux?

Install sshpass on Linux Systems In RedHat/CentOS based systems, first you need to enable Epel repository on your system to install it using yum command as shown. On Debian/Ubuntu and its derivatives, you can install it using apt-get command as shown.


1 Answers

you will need to install sshpass on the client server you are running your code in which is a tool that is not installed by default on most Linux distro

if you are in Ubuntu use this command

apt-get install sshpass

on centOS/redhat use this install epel

wget https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm

rpm -ivh epel-release-6-8.noarch.rpm

install sshpass

yum --enablerepo=epel -y install sshpass

Thanks

like image 65
Hani Avatar answered Sep 22 '22 18:09

Hani