in reply to Need help in doing SFTP via command line

Thanks for the suggestions
However the nature of my application is such that I have to connect to the SFTP server each time , with newly generated credentials to upload some files
So I do require a way in which , I should be able to log on to the SFTP server with the new set of credentials, drop my files , and then close the connection
Currently via command line when I do something like `sftp $userName\@$url ` , it actually prompts the user to put the password , which has been generated on the screen
I wanted to get control over the user Interaction , by trying to add the password via my perl program itself
In perl , is there any way to prevent the interactive user mode and to force the user entries via the program itself ?
Thanks Once Again
  • Comment on Re: Need help in doing SFTP via command line

Replies are listed 'Best First'.
Re^2: Need help in doing SFTP via command line
by Corion (Patriarch) on Oct 14, 2016 at 06:28 UTC

    Have you looked at Net::SFTP::Foreign? It allows you to pass in the password, at least on unixish systems.

      Hello, Thanks for the suggestion. Yes I was able to instal Net::SFTP::Foreign and I was able to successfully connect to the server.
      The place where I am stuck is when I try to do a 'Put'. I get the following message
      put failed: the authenticity of the target host can't be established, +the remote host public key is probably not present on the '~/.ssh/kno +wn_hosts' file
      The reason being that there seems to be an offending key in the ssh/known_hosts file , which has to be overidden.
      I tried to do the same thing from the command line and I got the following result. From the command line , I can select the option "yes" for it to continue connecting to the server , but I do not know if I can do the same thing from the STP::Foreign module
      Here is my command line output
      sftp 2000550000506913@sftp.XXX.com@upload-itms6.XXX.com Warning: the ECDSA host key for 'upload-itms6.XXX.com' differs from th +e key for the IP address '152.125.77.44' Offending key for IP in /Users/punitpawar/.ssh/known_hosts:2 Matching host key in /Users/punitpawar/.ssh/known_hosts:7 Are you sure you want to continue connecting (yes/no)? yes 2000550000506913@sftp.XXX.com@upload-itms6.XXX.com's password:
        The reason being that there seems to be an offending key in the ssh/known_hosts file , which has to be overidden.

        You can remove it with ssh-keygen.

        If you search the documentation for known_hosts, you find there several approaches on how to deal with this situation.