Skip to content

Default prompt for SSH session should include USERNAME/LOGNAME #7156

Closed

Description

This is a suggestion that would bring PowerShell more into line with Bash. For instance, if I ssh from my Windows 10 OpenSSH enabled system to a RHEL7 box, this is the prompt I get from Bash:

PS C:\> ssh mctcbld@es-kalbuild-rh.acme.com
mctcbld@es-kalbuild-rh.acme.com's password:
Last login: Thu Jun 21 09:51:35 2018 from stacy1.acme.com
Kickstarted on 2016-02-26
[mctcbld@AD.ACME.COM@es-kalbuild-rh ~]$

This system has PowerShell Core 6.0.1 installed on it and if I open a PSSession to it, I get the hostname in the default prompt but not the username/logname. FWIW I never log into this system as myself so it is very useful to see what user I'm logged in as.

> Enter-PSSession -HostName es-kalbuild-rh.acme.com -UserName mctcbld
mctcbld@es-kalbuild-rh.acme.com's password:
[es-kalbuild-rh.acme.com]: PS /home/mctcbld>

The default prompt I'd like to see is:

[mctcbld@es-kalbuild-rh]: PS /home/mctcbld>
# or maybe even
[mctcbld@AD.ACME.COM@es-kalbuild-rh]: PS ~>

I don't need to see the DNS suffix - just the hostname.

Finally, the docs I see for configuring powershell as a subsystem of sshd, say to use -NoProfile but then how could you configure/customize this prompt for the SSH transport?

Activity

  1. added
    Issue-Enhancement
    WG-Remoting
    on Jun 24, 2018
  2. iSazonov commented on Jun 24, 2018

    @iSazonov
    Collaborator

    Paul Higinbotham (@PaulHigin) Could please comment the Issue?

  3. PaulHigin commented on Jun 25, 2018

    @PaulHigin
    Contributor

    Including the current user in the prompt seems like a personal choice. PowerShell remoting automatically prepends "[computerName]: " to the current prompt to indicate the target machine name, but does not include the current user name.

    But you can easily include the user name by changing the prompt function in your remote session. Something like:

    function prompt { "[$(whoami)]: PS $($executioncontext.sessionstate.Path.CurrentLocation)$('>' * ($nestedPromptLevel+1)) "

    But we don't yet support configured endpoints for SSH based remoting so you would have to manually run a script file to change the prompt for each session. Once we have configured endpoints then you could simply configure the prompt with a "startup" script.

  4. rkeithhill commented on Jun 25, 2018

    @rkeithhill
    CollaboratorAuthor

    Don't you think most Linux folks would expect to see the username as well? Every Linux system I've ssh'd into shows me the username in the prompt.

    What would be cool is if the remote session would display [<username>@<hostname>]: if the remote username is different than the client side username. And if they're the same, just display [<hostname>]: like it does now. :-)

  5. PaulHigin commented on Jun 25, 2018

    @PaulHigin
    Contributor

    Sure, it would be easy to do this by default. Just update the remoting prompt code.

  6. SteveL-MSFT commented on Jun 26, 2018

    @SteveL-MSFT
    Member

    Paul Higinbotham (@PaulHigin) can you point to where in the source that prompt code exists?

  7. PaulHigin commented on Jun 26, 2018

    @PaulHigin
    Contributor

    EnterPSSessionCommand.SetRunspacePrompt() (PushRunspaceCommand.cs)

  8. SteveL-MSFT commented on Jun 26, 2018

    @SteveL-MSFT
    Member

    Paul Higinbotham (@PaulHigin) there must be some other location for the default prompt that shows the [hostname] as modifying SetRunspacePrompt() doubles it:

    [hostname]: [user@hostname]: PS /home/user>

  9. SteveL-MSFT commented on Jun 27, 2018

    @SteveL-MSFT
    Member

    Nevermind, found it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-EnhancementResolution-FixedWG-Remoting

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions