SFTP script still asking password


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SFTP script still asking password
Prev   Next
# 1  
Old 09-16-2017
SFTP script still asking password

Hi All,
I have FTP script snippet

Code:
targetFTP=testcomp
userID=testid
userPass=XXXXX

server_availability ()
{
echo "***********************************************************" >> $FtpLog
echo "*         Server Availability & User Access Checks        *" >> $FtpLog
echo "***********************************************************" >> $FtpLog
ftp -vn $targetFTP <<EOF
user $userID $userPass
pass
bye
EOF
echo "***********************************************************" >> $FtpLog
}


transfer_file ()
{
echo "***********************************************************" >> $FtpLog
echo "*                    File Extraction                      *" >> $FtpLog
echo "***********************************************************" >> $FtpLog
ftp -vn $targetFTP <<EOF
user $userID $userPass
pass
bi
lcd $inputDir
cd $outputDir
pwd
mput fiedel-$TDATE*.csv
bye
EOF
echo "***********************************************************" >> $FtpLog
}

Now requirement is to transfer via SFTP due to security restriction.

1. What I did I have generated Public key ssh-keygen and hosted that key to the target machine for password less authentication

2. replace FTP as SFTP as below and run but still it is interactive.

3. how i can make it non interactive so it will not ask password.



targetFTP=testcomp
userID=testid


Code:
server_availability ()
{
echo "***********************************************************" >> $FtpLog
echo "*         Server Availability & User Access Checks        *" >> $FtpLog
echo "***********************************************************" >> $FtpLog
sftp userID$targetFTP<<EOF
pass
bye
EOF
echo "***********************************************************" >> $FtpLog
}


transfer_file ()
{
echo "***********************************************************" >> $FtpLog
echo "*                    File Extraction                      *" >> $FtpLog
echo "***********************************************************" >> $FtpLog
sftp userID@$targetFTP<<EOF
pass
bi
lcd $inputDir
cd $outputDir
pwd
mput fiedel-$TDATE*.csv
bye
EOF
echo "***********************************************************" >> $FtpLog
}

scriptoutpt

Code:
$./test.sh
Thiscomputer system  is FOR OFFICIAL USE ONLY.
sysftp@testcomp's password:


Last edited by rbatte1; 09-25-2017 at 08:52 AM.. Reason: wrapped in CODE TAG
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

2. Shell Programming and Scripting

How to run sftp in shell script without prompting for password?

Hi, Can anyone tell me how to pass password in a shell script for sftp so that i can run it in background without user entering the password? I used a expect script but it timesout after some time and the process remains incomplete at the end. Can anyone suggest any other idea? Will the... (3 Replies)
Discussion started by: Little
3 Replies

3. Shell Programming and Scripting

SFTP prompting for password even though password is in script

Hi All, I am trying to transfer a file from one server to a remote server using SFTP. Client is not ready for key setup. I am working on Solaris 10. Here is the code. #!/bin/ksh # sample automatic Sftp script to dump a file USER="user1" PASSWORD="pass1" HOST="host1" sftp $USER@$HOST... (6 Replies)
Discussion started by: megha2525
6 Replies

4. UNIX for Dummies Questions & Answers

Script to log in SFTP server [with username, password]

Hi, everyone, I am trying to write a script to login automatically using username and password to an sftp server (the key authentication has been disabled so I cannot use that method). I tried to search online for a solution and found a way using "expect" but my boss does not want me to use... (4 Replies)
Discussion started by: warmboy610
4 Replies

5. Shell Programming and Scripting

SFTP password through shell script.

Hi All, I would be happy, if someone help me on this that I have only SFTP ID and Password to transfer some log files from webserver boxes to SFTP server Anyone help me that how to pass the password parameter throough the shell scripts, since i don't have ssh login access on the SFTP... (2 Replies)
Discussion started by: l_gshankar24
2 Replies

6. Shell Programming and Scripting

sftp batch script with password

I am working on a sftp batch script on a Solaris machine and I need to connect using password. This is not an issue when i do it manually but when I want to make this into a script, i find there are no options for password. Can anyone suggest how I can do it with password? I know using keys is... (3 Replies)
Discussion started by: Leion
3 Replies

7. Shell Programming and Scripting

sftp shell script - Password read error.

Hi, I have script which does the sftp function. In the script in one place it able to read the password from file and other place files with below error. warning: has much more security than supplying the password in the clear warning: on the command line. Failed to get password: File... (0 Replies)
Discussion started by: vino_hymi
0 Replies

8. HP-UX

sftp/scp/ssh script with password as authentication

Hello, Do you guys know set of commands that can incorporate to sftp/scp/ssh to add password in a script to automate file transfer. Our client is not using ssh keys authentication so we are force to create a script to pass the password into the script to transfer files via sftp/scp/ssh. We... (4 Replies)
Discussion started by: james_falco
4 Replies

9. Shell Programming and Scripting

SFTP in Shell Script with RSA-KEY or password.

I am trying to SFTP to a couple sites. One has an RSA-KEY that was sent to me. Currently I am running that manually using WinSCP. I would like to set it up as a CRON process on our Linux host (Sun). Can I use the rsa-key they sent me in any directory or does it need to be placed in a specific... (2 Replies)
Discussion started by: alemat
2 Replies

10. UNIX for Advanced & Expert Users

Change the password in 30 days in sftp script.

Hi, I'm writing a script which actually sftp's(gets!! i'm using mget) files from a windows box to unix server. (i've gone thru forum and got pretty good answers, Thx for that). but the windows box to which i'm ftp'g prompts for a password change every 30 days. so please suggest me how to do... (3 Replies)
Discussion started by: rosh0623
3 Replies
Login or Register to Ask a Question