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 [email protected]

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

0

1 Answer 1

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:-

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.