SFTP script to automate login in to remote server

Greetings, guys. I'm not much of a programmer forgive me for being a noob, because of someone leaving, I was put in an IT spot where I have to figure out a few things. Being new to Linux and programming has been a challenge.

My boss has asked me to create an automated script to connect to a 3rd party vendor to transfer files automatically on a set day of the month. Unfortunately, the problem is that the 3rd party does NOT use or allow the use of SSH Key exchanges, so I'm stuck trying to make use of automating the sFTP program. I read somewhere there is an non-interactive mode but I was hoping I could pick the brains of some of you guys, which are so much more experienced than I. I appreciate all answers in advance.

Gio

SSH keys are the noninteractive mode.

If they don't allow keys, then they probably don't allow automation, period. I'm sure they'd be livid to discover you automating it in blatantly insecure ways just because they didn't allow you to use the proper way.

You'd have to use a third-party brute forcing utility like expect and accept the security consequences of this poor practice.

Thank you for your reply Corona, much appreciated. Yeah the 3rd party doesn't allow it, which seemed kinda weird to me. Ok, I'll look into the expect utility. Thanks again Corona.

look at this post for a sample "automated" ftp script not using expect ...

try searching the forums first if you have other issues. more than a few of the people here have been doing this longer than some of us have been alive so they have already seen or heard a lot of the issues reported here. good luck!

Thank you so much for your reply Just Ice

I actually did see that script when I searched and tried it. Unfortunately it's just ftp, I was trying to do that with sFTP and it would get stuck in interactive mode and wouldn't connect. I couldn't find anything solid regarding that so that's why I asked. Thanks again for your help. I appreciate everyones input, as a newb that I am :slight_smile:

Now that you know the magic word 'expect' your searches should be more fruitful.

See example #6 here: 6 Expect Script Examples to Expect the Unexpected (With Hello World)
As someone else suggested in this same thread, make sure your manager and your client understand that this is poor practice and certainly NOT the best way to get things done.

if the issue still exists, please the script you are using as well as the errors being generated ...