SSH SFTP with UserName/Password Authentication

Any IBM i topic that does not fit in another forum
Post Reply
Pmaric
Posts: 6
Joined: Sun Mar 30, 2025 9:46 am

SSH SFTP with UserName/Password Authentication

Post by Pmaric »

We have 2 trading partners who want us to start using SFTP over Port 22 with user/password authentication. Both have said keys should not be needed. Before attempting to create a script, I am trying first to connect interactively. On both partner's connections, I connect, it asks for password, then I get the following error:

tcgetattr: Invalid argument

I am reading something about terminals, which is not clear to me. Any help would be most appreciated.
Pmaric
Posts: 6
Joined: Sun Mar 30, 2025 9:46 am

Re: SSH SFTP with UserName/Password Authentication

Post by Pmaric »

Also, I have set up connections using public/private keys successfully in the past, so I am familiar with the basics.
Pmaric
Posts: 6
Joined: Sun Mar 30, 2025 9:46 am

Re: SSH SFTP with UserName/Password Authentication

Post by Pmaric »

Over 1000 views and no responses? :) OK, I'll research more and post my solution here.
gmalchow
Posts: 8
Joined: Fri Aug 30, 2024 8:40 pm

Re: SSH SFTP with UserName/Password Authentication

Post by gmalchow »

You don't happen to have a dash in your password do you?

When you are connecting, are you using something like putty, or winscp? Is it possible that however you are connecting isn't a true tty?

Can the admin of the server offer any help?
Pmaric
Posts: 6
Joined: Sun Mar 30, 2025 9:46 am

Re: SSH SFTP with UserName/Password Authentication

Post by Pmaric »

Thanks!

There is no dash in the password. It may very well be possible I am connecting to something that isn't a true tty. I guess I need to find out what a true tty is. :)

I am using the AS400 to connect, from a command line -- STRQSH, then manually entering the FTP script.

ssh user@partner.ip

It connects, asks for password, then I get that message - "tcgetattr: Invalid argument"

The admin of the server has gone silent. Maybe I'll email again.
gmalchow
Posts: 8
Joined: Fri Aug 30, 2024 8:40 pm

Re: SSH SFTP with UserName/Password Authentication

Post by gmalchow »

I believe that 5250 terminal sessions started from STRQSH or CALL QP2TERM are not true tty devices. Can you try using something like putty to verify you can connect and authenticate to the sshd (server)?

Assuming the SFTP client is running on an IBM i, and you are required to authenticate with a password to the sshd, you will need to use a tool like Expect.

Scott published a document titled "Scripting the OpenSSH, SFTP, and SCP Utilities in i". That document was instrumental in me understanding how to use SFTP where I had to authenticate with a password.
Pmaric
Posts: 6
Joined: Sun Mar 30, 2025 9:46 am

Re: SSH SFTP with UserName/Password Authentication

Post by Pmaric »

I just read our illustrious leader's (SK) write-up on SFTP. Since I am using a 5250 terminal, perhaps it can't be done with password authentication. I will try to get them to use the keys authentication.
Pmaric
Posts: 6
Joined: Sun Mar 30, 2025 9:46 am

Re: SSH SFTP with UserName/Password Authentication

Post by Pmaric »

OK, I sent them a key, and all is good. II just had to change the command from ssh user@IP to sftp user@IP.
Post Reply