{"action":"created","issue":{"url":"https://api.github.com/repos/darkoperator/Posh-SSH/issues/173","repository_url":"https://api.github.com/repos/darkoperator/Posh-SSH","labels_url":"https://api.github.com/repos/darkoperator/Posh-SSH/issues/173/labels{/name}","comments_url":"https://api.github.com/repos/darkoperator/Posh-SSH/issues/173/comments","events_url":"https://api.github.com/repos/darkoperator/Posh-SSH/issues/173/events","html_url":"https://github.com/darkoperator/Posh-SSH/issues/173","id":257661355,"number":173,"title":"New-SSHSession and New-SFTPSession have an issue in powershell workflow","user":{"login":"SheGe","id":3687447,"avatar_url":"https://avatars1.githubusercontent.com/u/3687447?v=4","gravatar_id":"","url":"https://api.github.com/users/SheGe","html_url":"https://github.com/SheGe","followers_url":"https://api.github.com/users/SheGe/followers","following_url":"https://api.github.com/users/SheGe/following{/other_user}","gists_url":"https://api.github.com/users/SheGe/gists{/gist_id}","starred_url":"https://api.github.com/users/SheGe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SheGe/subscriptions","organizations_url":"https://api.github.com/users/SheGe/orgs","repos_url":"https://api.github.com/users/SheGe/repos","events_url":"https://api.github.com/users/SheGe/events{/privacy}","received_events_url":"https://api.github.com/users/SheGe/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-09-14T09:56:51Z","updated_at":"2017-11-30T09:20:57Z","closed_at":"2017-10-13T20:24:46Z","author_association":"CONTRIBUTOR","body":"The `New-SSHSession` and `New-SFTPSession` functions have an issue in usage of them in powershell workflow.\r\n\r\n## Exception\r\n```\r\nThe server did not respond with an encrypted session key within the specified time-out period.\r\nAt Test-SSH:12 char:12\r\n+\r\n    + CategoryInfo          : NotSpecified: (:) [Write-Error], PSRemotingDataStructureException\r\n    + FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerShell.Commands.WriteErrorCommand\r\n    + PSComputerName        : [localhost]\r\n```\r\n\r\n## Test environment\r\n\r\n* Tested Posh-SSH versions: `1.7.7` `2.0.1`\r\n* SSH host is a CentOS in intranet with SSH enabled\r\n\r\n## Repro script\r\n\r\n```powershell\r\nImport-Module Posh-SSH\r\n\r\n$Global:sshPassword = \"xyzPass\"\r\n$Global:sshUser = \"zyxUser\"\r\n$Global:sshHostName = \"hostname\"\r\n\r\nworkflow Test-SSH\r\n{\r\n    parallel\r\n    {\r\n        OpenFirsSshConnection\r\n    }\r\n\r\n    function OpenFirsSshConnection()\r\n    {\r\n        $Global:sshPassword = \"xyzPass\"\r\n        $Global:sshUser = \"zyxUser\"\r\n        $Global:sshHostName = \"hostname\"\r\n\r\n        function GetCredential()\r\n        {\r\n            $securePassword = ConvertTo-SecureString -String $Global:sshPassword -AsPlainText -Force\r\n            return New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Global:sshUser, $securePassword\r\n        }\r\n\r\n        Write-Host \"Opening first ssh connection $($Global:sshHostName) (user: $($Global:sshUser), password: $($Global:sshPassword))\"\r\n        $session = $null\r\n\r\n        try\r\n        {\r\n            $credential = GetCredential\r\n            $session = New-SSHSession -ComputerName $Global:sshHostName -Port \"22\" -Credential $credential -AcceptKey -Force -Verbose\r\n            $result = Invoke-SSHCommand -SSHSession $session -Command \"hostname\"\r\n            Write-Host \"OpenFirstSshConnection says: $($result.Output)\"\r\n        }\r\n        catch\r\n        {\r\n            Write-Error \"Exception in first ssh connection (session details: $session): $_\"\r\n            throw\r\n        }\r\n\r\n        Write-Host \"First ssh connection opened successfuly. Session details: $session\"\r\n   }\r\n}\r\n\r\nfunction OpenZeroSshConnection()\r\n{\r\n    function GetCredential()\r\n    {\r\n        $securePassword = ConvertTo-SecureString -String $Global:sshPassword -AsPlainText -Force\r\n        return New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Global:sshUser, $securePassword\r\n    }\r\n\r\n    Write-Host \"Opening zero ssh connection $($Global:sshHostName) (user: $($Global:sshUser), password: $($Global:sshPassword))\"\r\n    $session = $null\r\n\r\n    try\r\n    {\r\n        $credential = GetCredential\r\n        $session = New-SSHSession -ComputerName $Global:sshHostName -Port \"22\" -Credential $credential -AcceptKey -Force -Verbose\r\n        $result = Invoke-SSHCommand -SSHSession $session -Command \"hostname\"\r\n        Write-Host \"OpenZeroSshConnection says: $($result.Output)\"\r\n    }\r\n    catch\r\n    {\r\n        Write-Error \"Exception in first ssh connection (session details: $session): $_\"\r\n        throw\r\n    }\r\n\r\n    Write-Host \"Zero ssh connection opened successfuly. Session details: $session\"\r\n}\r\n\r\nOpenZeroSshConnection\r\nTest-SSH\r\n```\r\n\r\n**Execution result**\r\n```\r\nOpening zero ssh connection ******* (user: automation, password: ********)\r\nVERBOSE: Using SSH Username and Password authentication for connection.\r\nWARNING: Host key is not being verified since Force switch is used.\r\nOpenZeroSshConnection says: *************\r\nZero ssh connection opened successfuly. Session details: SSH.SshSession\r\nOpening first ssh connection *********** (user: ********, password: ********)\r\nMicrosoft.PowerShell.Utility\\Write-Error : The server did not respond with an encrypted session key within the specified time-out period.\r\nAt Test-SSH:12 char:12\r\n+\r\n    + CategoryInfo          : NotSpecified: (:) [Write-Error], PSRemotingDataStructureException\r\n    + FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerShell.Commands.WriteErrorCommand\r\n    + PSComputerName        : [localhost]\r\n```"},"comment":{"url":"https://api.github.com/repos/darkoperator/Posh-SSH/issues/comments/348129325","html_url":"https://github.com/darkoperator/Posh-SSH/issues/173#issuecomment-348129325","issue_url":"https://api.github.com/repos/darkoperator/Posh-SSH/issues/173","id":348129325,"user":{"login":"adjosan","id":5493203,"avatar_url":"https://avatars2.githubusercontent.com/u/5493203?v=4","gravatar_id":"","url":"https://api.github.com/users/adjosan","html_url":"https://github.com/adjosan","followers_url":"https://api.github.com/users/adjosan/followers","following_url":"https://api.github.com/users/adjosan/following{/other_user}","gists_url":"https://api.github.com/users/adjosan/gists{/gist_id}","starred_url":"https://api.github.com/users/adjosan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adjosan/subscriptions","organizations_url":"https://api.github.com/users/adjosan/orgs","repos_url":"https://api.github.com/users/adjosan/repos","events_url":"https://api.github.com/users/adjosan/events{/privacy}","received_events_url":"https://api.github.com/users/adjosan/received_events","type":"User","site_admin":false},"created_at":"2017-11-30T09:20:57Z","updated_at":"2017-11-30T09:20:57Z","author_association":"NONE","body":"the session was not created, i'm using VM on ubuntu server 16.04 LTS"}}
{"actor":{"display_login":"adjosan"}}