0

I am trying the below command but didn't get any output:

echo "put C:\Users\abhishek.chawla\Desktop\AbhishekC_bills.zip deployment/AbhishekC_bills.zip" | sftp TESTSHELTER@shelter-ftp.outlinesys.com

Do I need to add the password too? If yes, then where to add the password?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

1

One of the workaround you can follow ,

To provide the password into the command for upload files to SFTP using PowerShell through Winscp below is the example of code.

cmdltes:-

Add-Type -Path "WinSCPnet.dll"

$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "example.com"
    UserName = "user"
    Password = "mypassword"
    SshHostKeyFingerprint = "ssh-rsa 2048 xx...="
}
$session = New-Object WinSCP.Session
try
{
    $session.Open($sessionOptions)
    $session.PutFiles("C:\users\export.txt","/Outbox/").Check()
}
finally
{
    $session.Dispose()
}

For complete information please refer this BLOG|Use WinSCP to Upload Files to SFTP Site With PowerShell .

For more information regarding similar issue please refer the below links:-

AjayKumarGhose
  • 4,257
  • 2
  • 4
  • 15