Batch CL for sFTP with Password Authentication

Any IBM i topic that does not fit in another forum
Post Reply
cea_1964@yahoo.com
Posts: 7
Joined: Wed Sep 14, 2022 2:22 am

Batch CL for sFTP with Password Authentication

Post by cea_1964@yahoo.com »

I received a new request to send files via sFTP to a new trading partner.
After copying a previous setup, and changing the scripts, I continue to get Permission Denied.

Key is in /home/skxftp/.ssh
- myftp.dachser.com,195.145.171.89 ecdsa-sha2-nistp256 AAAAE.......
The script is stored in /home/skxftp/Src/dac_sftp_script.sh
- #!/bin/sh
- export DISPLAY= SSH_ASKPASS=/QOpenSys/etc/Dac_password_script.sh
- printf "lcd /Home/Skxftp/Out/Dac/\ncd /data/edi/da00127976/in\nput *.csv\nquit\n" | sftp -vvv -oStrictHostKeyChecking=no
-oPasswordAuthentication=yes USER001@myftp.dachser.com
The password is stored in /QOpenSys/etc/Dac_password_script.sh
- #!/bin/sh
- printf PASSWORD001

I constantly get the read_passphrase: can't open /dev/tty: No such device or address!!!

This setup works well with other partners.

What should i be checking, or have the partner check?

Thanks in advance.

Chris
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: Batch CL for sFTP with Password Authentication

Post by Scott Klement »

On Unix systems, "tty" (teletype) is synonymous with "terminal". So what this error message is telling you is that it's trying to read the password from the terminal -- and it can't because there is no terminal associated with your session.

This tells me that, for some reaon, SSH_ASKPASS i not working in this script. If it were working, it'd get the password from that script instead of the terminal.

I don't know why SSH_ASKPASS isn't working -- I'm not familiar with SSH_ASKPASS.

But, this definitely doesn't seem to have anything to do with the partner. The problem is completely on your side of the connection.
cea_1964@yahoo.com
Posts: 7
Joined: Wed Sep 14, 2022 2:22 am

Re: Batch CL for sFTP with Password Authentication

Post by cea_1964@yahoo.com »

Do you think the Expect tool would resolve my issue?
cea_1964@yahoo.com
Posts: 7
Joined: Wed Sep 14, 2022 2:22 am

Re: Batch CL for sFTP with Password Authentication

Post by cea_1964@yahoo.com »

Also, the key added to our known host was an id_ecdsa. Should i also have an id_ecdsa key pair in .ssh?
cea_1964@yahoo.com
Posts: 7
Joined: Wed Sep 14, 2022 2:22 am

Re: Batch CL for sFTP with Password Authentication

Post by cea_1964@yahoo.com »

I have it working.
The password contained a "$", which was sending some type control break, or being converted, or.......whatever.

In the log, I noticed the password was truncated at the position where the "$" was located. So, I put single quotes around the pw in the password script .sh file. Viola!!!

Thanks, and hope to see you soon.

Chris
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: Batch CL for sFTP with Password Authentication

Post by Scott Klement »

The $ character has a special meaning in a shell script, so to put a $ in your SSH_ASKPASS script you would need to escape it properly.
Post Reply