Sftp connection with password


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sftp connection with password
# 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

Script:-

Code:
PASSWORD="xyz"
sftp -oport=1002 user@host:/dir/archive/file*.txt  /di/data/
<< EOF
$PASSWORD
quit
EOF

Got error :-

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


Please suggest on this.


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by rbatte1; 04-16-2018 at 01: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.

Code:
ssh-keygen
...
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.


Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

New sftp connection

Dear All , I have a openssh 4.3p2 , but i need to configure sftp for a user which is present in the server. This user has to see only the specific directory not all. I tried to do the changes in sshd_config for openssh 4.9p1 , but for openssh 4.3p2 how to do it. Any one pl help. ... (1 Reply)
Discussion started by: jegaraman
1 Replies

2. IP Networking

SFTP connection using two different users

Hi All This is regarding an SFTP Password less connection. I am logged into my local Server1 using username1. The remote server i have to connect is "Remoteserver1" with the "useriD" provided. I have already exchanged the public key and they are added to the authorized keys in the remote... (2 Replies)
Discussion started by: sparks
2 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

SFTP: Connection problem

HI, I have generated public key and placed in remote server. When I am trying to do SFTP for that remote server the below error I am getting. Please help me to resolve Connecting to hostname... Sun_SSH_1.1.4, SSH protocols 1.5/2.0, OpenSSL 0x0090704f debug1: Reading configuration data... (4 Replies)
Discussion started by: rangarasan
4 Replies

5. Shell Programming and Scripting

Setup sftp connection

To set up a sftp connection between Server A, Server B and a website.com A batch script will start from Server A and Server B and Connect to the Website server How to setup sftp connection between server's. (1 Reply)
Discussion started by: aix_admin_007
1 Replies

6. UNIX for Dummies Questions & Answers

For SFTP connection - How to give password in UNIX Script (ksh)

Hi, I am not able to give the password in Unix script for SFTP connection. When I am trying to manully SFTP command for accessing the server , it asking for pwd and I could provide the pwd but I am not getting how to provide the pwd inside the Unix script. sftp -v user@xyz.com. ... (4 Replies)
Discussion started by: Vineeta Nigam
4 Replies

7. Shell Programming and Scripting

How to check sftp connection

Hi All, in our system , the sftp server is continuously up. but suddenly it is brought down. how can i find out the reason behind of these , is their any log files or how can i check the connectvity with sftp. please help me to solve this issue (1 Reply)
Discussion started by: aish11
1 Replies

8. UNIX for Dummies Questions & Answers

SFTP Connection error

Hi I when I trying to SFTP a file to a server I am getting this below error: Connecting to 3.12.911.100... ssh_askpass: exec(/usr/lib/ssh/ssh-askpass): No such file or directory Host key verification failed. Connection closed Can you please help me in debugging this error. ... (3 Replies)
Discussion started by: krishna87
3 Replies

9. Shell Programming and Scripting

SFTP connection problem

Dear All, I'm trying to configure the passwordless connection between two servers say Server A and Server B. My requirement is a passwordless connection from Server A to Server B. I have done the configuration in both the servers. In Server A its successfull but from Server B its everytime... (7 Replies)
Discussion started by: panknil
7 Replies

10. Shell Programming and Scripting

Password less connection(sftp/ssh)

Dear All, I'm trying to configure a passwordless connection between two servers of HP-UX. i have srearched the configuration in google so many times and as per the guidence i have done all the steps, but still its not working and every time it is asking for password while trying to scp some file... (2 Replies)
Discussion started by: panknil
2 Replies
Login or Register to Ask a Question