darkoperator / darkoperator/Posh-SSH

Inconsistent Behavior in Azure Automation

Open
#478 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
1.1k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

I need to write a script to grab a file form aws and upload via SFTP. Seemed simple to me.I am doing it in Azure Automation in a Runbook.

I enabled the post-ssh module and made my code. but the execution is inconsistent at best.

I normally get this on the verbose output:
Using SSH Username and Password authentication for connection.
ssh-ed25519 Fingerprint for sftp.myserver.com: ba:79:3d:78:1f:57:3c:37:20:33:5d:5d:xxxxx
Set host key for sftp.myserver.com to ba:79:3d:78:1f:57:3c:37:20:33:5d:5d:xxxxxx

But then I will get "Client Not Connected" or I get "An established connection was aborted by the server"
Or, I get a proper connection showing me the session ID but then the next command immediately to post a file I get the above "established connection..." message.

Or, it will simply work! And each time I run it I am in the Runbook Editor test panel and I simply click "start" over and over and I get a different result every time.

It is like it doesn't remember from one moment to the next. I am not changing any code.

The core of the code I'm using is this:
$SFTP = New-SFTPSession -ComputerName $pcURL -Port $pcPort -Credential $ProCareSFTP -ConnectionTimeout 45 -OperationTimeout 45 -KeepAliveInterval 45 -AcceptKey -Verbose

Write-Output $SFTP.SessionID

Set-SFTPItem -SessionID $SFTP.SessionID -Destination "/sandbox" -Path "testing.txt"

I added all the timeouts and keep alive values to see if that would help but it doesn't.

What is going on? does this not work with Azure Automation? It will work 100% of the time with an Azure powershell connection or a personal connection.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Azure Automation Runbook test panel and reproduce the inconsistent results using New-SFTPSession followed by Set-SFTPItem. Compare the successful and failed verbose outputs, including connection, timeout, keep-alive, and session ID behavior. Done means the Azure Automation-specific cause is identified and the SFTP upload behaves consistently or the limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.