in reply to Re: Need help in doing SFTP via command line
in thread Need help in doing SFTP via command line

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

  • Comment on Re^2: Need help in doing SFTP via command line

Replies are listed 'Best First'.
Re^3: Need help in doing SFTP via command line
by punitpawar (Sexton) on Oct 17, 2016 at 16:58 UTC
    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.

        It seems that I cannot connect to the SFTP server in the first place I get the following error:
        Connecting to SFTP Server unable to connect to remote host: the authenticity of the target host +can't be established, the remote host public key is probably not pres +ent on the '~/.ssh/known_hosts' file
        As suggested I tried using ssh-keyagent to get rid of the conflicting keys but that did not help
        ## doing a ssh-keygen print "\n Disabling StrictHostKeyChecking \n"; my %opts =(password => $password); my $ssh = Net::OpenSSH->new($hostName, %opts, master_opts => [-o => "StrictHostKeyChecking=no"] ); ## Connecting to SFTP server print "\n Connecting to SFTP Server \n"; my $sftp = Net::SFTP::Foreign->new(host => $url, user => $userName, password => $password ); $sftp->die_on_error("unable to connect to remote host");
        Any help on this will really be appreciated. I am stuck and not sure what to do...

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