darkoperator / darkoperator/Posh-SSH

Cannot change initial SSH password of device

Open
#616 22 comments 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

The device in question is an UPS. Upon initial ssh connection it comes up with

You must change your password now and login again!
Changing password for local\admin
Old password:

Now with an actual ssh session I can enter "admin", since this is the default password, hit "enter" and then I can or could set the new password.

However with Posh-SSH 3.2.4, on Server 2022 Powershell 5.1 in Powershel_ISE, it does not work. Since it is needed over a large number of devices Posh-SSH is my first choice here since it worked well on a different project. However I always get "Incorrect password"

The actual commands are:

$SshSession = New-SSHSession -ComputerName $SSHTarget -Credential $Credential -AcceptKey -Verbose -ErrorAction Stop
$SSHStream = New-SSHShellStream -SSHSession $SshSession
Start-Sleep 2
$SSHStream.Read()

The console answers with:

Credentials are expired
Min password length: 8
Max password length: 32
Min uppercase characters: 1
Min lowercase characters: 1
Min digits: 1
Min special characters: 1
Valid special characters: `~!@#$%^&*()_-+={}[]|:;\"<>,.'?/
Last login: Mon Aug 11 11:41:32 2025 from 169.254.5.76
WARNING: Your password has expired.
You must change your password now and login again!
passwd: no record of local\admin in /etc/shadow, using /etc/passwd
Changing password for local\admin
Old password: 

I then use:
$SSHStream.WriteLine("admin")
And the result is:

$SSHStream.read()
Incorrect password
passwd: password for local\admin is unchanged

Variation I tried:

$SSHStream.Write("admin`n")

, same result.
I also tried $SshSession.Session.ConnectionInfo.Encoding = [System.Text.Encoding]::ASCII and $SSHStream.Session.ConnectionInfo.Encoding = [System.Text.Encoding]::ASCII before even reading the opened stream.
Checking the encoding before and after shows it is applied:

PS:>$SshSession.Session.ConnectionInfo.Encoding

BodyName          : utf-8
EncodingName      : Unicode (UTF-8)
HeaderName        : utf-8
WebName           : utf-8
WindowsCodePage   : 1200
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
IsSingleByte      : False
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 65001

PS:>$SshSession.Session.ConnectionInfo.Encoding = [System.Text.Encoding]::ASCII

PS:>$SshSession.Session.ConnectionInfo.Encoding

IsSingleByte      : True
BodyName          : us-ascii
EncodingName      : US-ASCII
HeaderName        : us-ascii
WebName           : us-ascii
WindowsCodePage   : 1252
IsBrowserDisplay  : False
IsBrowserSave     : False
IsMailNewsDisplay : True
IsMailNewsSave    : True
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 20127

PS:>$SSHStream.Session.ConnectionInfo.Encoding

BodyName          : utf-8
EncodingName      : Unicode (UTF-8)
HeaderName        : utf-8
WebName           : utf-8
WindowsCodePage   : 1200
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
IsSingleByte      : False
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 65001

PS:>$SSHStream.Session.ConnectionInfo.Encoding = [System.Text.Encoding]::ASCII

PS:>$SSHStream.Session.ConnectionInfo.Encoding

IsSingleByte      : True
BodyName          : us-ascii
EncodingName      : US-ASCII
HeaderName        : us-ascii
WebName           : us-ascii
WindowsCodePage   : 1252
IsBrowserDisplay  : False
IsBrowserSave     : False
IsMailNewsDisplay : True
IsMailNewsSave    : True
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 20127

After all my attempts I tried several time with a normal ssh client, and the old password is still "admin", which I can enter.
Now am I doing something terribly wrong or is this a Posh-SSH thing?

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 New-SSHSession and New-SSHShellStream entry points and reproduce the password-change flow against the UPS using the commands and prompts shown. Compare the shell stream's handling of the Old password input with a normal SSH client, and use the reported Posh-SSH 3.2.4 behavior to define whether the password change completes successfully.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.