Home Man
Today's Posts

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Sftp connection with password

sftp, shell, shell scripts

Login to Reply

Thread Tools Search this Thread
# 1  
Old 04-12-2018
Computer Sftp connection with password

I am running this script to copy pattern files in local but it is asking for password even passing the hardcode value


sftp -oport=1002 user@host:/dir/archive/file*.txt  /di/data/
<< EOF

Got error :-

-bash-4.1$ sh sftp_with_password.sh
Connecting to user@host...
Password Authentication

Please suggest on this.

Moderator's Comments:
Sftp connection with password Please use CODE tags as required by forum rules!

Last edited by rbatte1; 04-16-2018 at 12:26 PM.. Reason: RudiC Added CODE tags. rbatte1 took out auto-email formating
# 2  
Old 04-12-2018
Embedding passswords in clear text in scripts is bad practise and ssh/sftp is designed to prohibit such usage.

The first approach to take is to generate an SSH-Key and deposit the public key part in target hosts $HOME/.ssh/authorized_keys file.

ssh-copy-id user@host

If that does not work, try to find the error why.
# 3  
Old 04-12-2018
I don't have access to right SSH file. It is the only way to use hardcode
# 4  
Old 04-12-2018
Did you really try to write the file with sftp?


In case there's really no way, you may use sshpass for that case....

The source is located here:

SourceForge - sshpass

Major Linux Linux distributions have that package included.
# 5  
Old 04-12-2018
While using sshpass, it shows command not found
Do I need to install package and will it impact other job ?
# 6  
Old 04-16-2018
On the target server, can you use the credentials your have to sign in and look in the home directory for a .ssh directory? What permission do you have on that directory and particularly the authorized_keys file.

Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
New sftp connection jegaraman Red Hat 1 12-23-2015 01:51 PM
SFTP prompting for password even though password is in script megha2525 Shell Programming and Scripting 6 01-29-2014 01:01 PM
Setup sftp connection aix_admin_007 Shell Programming and Scripting 1 04-26-2013 04:58 AM
For SFTP connection - How to give password in UNIX Script (ksh) Vineeta Nigam UNIX for Dummies Questions & Answers 4 12-04-2012 10:15 AM
How to check sftp connection aish11 Shell Programming and Scripting 1 01-30-2012 10:04 AM
ssh/sftp connection refused isaacniu Shell Programming and Scripting 1 01-18-2012 07:00 AM
SFTP connection problem panknil Shell Programming and Scripting 7 12-16-2009 07:31 AM
Password less connection(sftp/ssh) panknil Shell Programming and Scripting 2 11-27-2009 11:04 AM
SFTP Connection Closed ed.browne UNIX for Advanced & Expert Users 1 07-23-2008 01:07 AM
ssh/sftp failure connection james_falco UNIX for Advanced & Expert Users 3 03-27-2007 11:19 AM

All times are GMT -4. The time now is 12:59 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
Show Password