0

using powershell posh-ssh , when i try this Approach A

$session = New-SSHSession -ComputerName $Server -Credential Get-Credential

i get this error

New-SSHSession: Permission denied (keyboard-interactive).

when i tried Approach B

$cred = Get-Credential

$session = New-SSHSession -ComputerName $Server -Credential $cred

it works!!!! but when i exit the session and open powershell session the error occurs when i try Approach B and it works when i try Approach A!!!!

i went to C:\OpenSSH-Win64\sshd_config_default i commented out PasswordAuthentication yes and restarted the service but still same, i made sure the sshd demon is running from C:\OpenSSH-Win64\sshd.exe

  • It is a fundamental syntax requirement in PowerShell to enclose _commands_ in `(...)` so as to allow them to act as _arguments_ to other commands (e.g. `ConvertFrom-Json (Get-Content -Raw file.json)`) and to participate in _expressions_ (e.g. `1 + (Write-Output 42)`). See the linked duplicate for details. – mklement0 May 28 '23 at 18:57
  • In other words: replace `-Credential Get-Credential` with `-Credential (Get-Credential)` – mklement0 May 28 '23 at 18:58

0 Answers0