darkoperator / darkoperator/Posh-SSH
New-SSHSession : An established connection was aborted by the server
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Description
Hi Team,
While am running the below PowerShell code getting the below error for few host IP's
New-SSHSession : An established connection was aborted by the server
request you to provide some solution
Code to connect to Cisco Devices
$userId = ""
$pwd = Get-Content "$userId.Pw.txt"
$pwd1 = ConvertTo-SecureString -AsPlainText $pwd -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $userId, $pwd1
#$enable = Get-Content "enable.txt"
$hostnames = Get-Content "<path/file>"
$ErrorActionPreference = 'Continue'
foreach($hostname in $hostnames)
{
$A = $ssh=New-SSHSession -ComputerName $hostname -Credential $cred -Force -OperationTimeout 300 -ConnectionTimeout 300
if ($A)
{
$ErrorOccured=$False
$stream = $ssh.Session.CreateShellStream("dumb", 0, 0, 0, 0, 1000)
$stream.Write("terminal length 0n")
$stream.Write("show inventoryn")
$stream.Write("show ip int brief | ex unassn")
$stream.Write("sh version | i Versionn")
$stream.write("enablen")
$stream.write("<enable>n")
$stream.Write("show runn | i comm`n")
Start-Sleep -Seconds 5
$streamoutput = $stream.read()
$streamoutput |Out-File "<path\file>"
Remove-SSHSession -SSHSession $ssh | Out-Null
}
else
{
#write-host "Something went wrong"
}
}
Regards,
Shivakumar T
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported PowerShell script and reproduce New-SSHSession against an affected Cisco host, comparing it with hosts that connect successfully. Investigate the server-aborted connection at session establishment; done means identifying a reproducible cause and documenting an actionable fix or the missing diagnostic information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100