WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Uncategorized / Quick Tip - How to Change ESXi SSH Prompt

Quick Tip - How to Change ESXi SSH Prompt

07.18.2013 by William Lam // 3 Comments

This quick tip was motivated by a comment from Jason Nash where he wished the hostname of an ESXi host is automatically displayed on the SSH prompt when logging into the system. Traditionally, systems providing SSH access will default the SSH prompt to use the format of [[email protected] current-working-directory], but for an ESXi host, it just displays the current working directory.

This is not that big of an issue, unless you have multiple connections opened up to various systems which is usually the case for the average System Administrator. Being able to quickly identify the host you on are without having to run the hostname command would be nice and I can see why Jason would want to have this. Having said that, this is something you can easily configure on ESXi as well as other UNIX/Linux system in terms of customizing the SSH prompt.

To change the SSH prompt on ESXi, you will need to edit /etc/profile.local configuration file and add PS1 environmental variable which controls the SSH prompt. The configuration file is automatically backed up and all changes will persist through a reboot.

If you want to enable the basic [[email protected] current-working-directory], add the following to the file:

PS1="[\[email protected]\h:\w] "

Now when you login to your ESXi host, the SSH prompt will look like this:

You can even add colors to your SSH prompt, if you add the following to the file:

PS1="\e[0;41m[\[email protected]\h \W]\$ \e[m"

It will look like this:

The above are just examples of the customization you can apply to the SSH prompt, for more options you can take a look at this reference or search for others online. You can also quickly test your changes by just setting the PS1 variable on the command-line and then logging in.

Since this is something that has annoyed me from time to time, I will be filing a Feature Request with engineering and hopefully we can have this as a default in the future. Thanks Jason for bringing this up!

More from my site

  • ESXi Google Authenticator Is Now A VMware Fling!
  • How To Compile Google Authenticator for ESXi
  • Using Google Authenticator To Provide Two-Factor Authentication For ESXi
  • ESXi on palm size iKOOLCORE R1
  • Quick Tip - Automating ESXi local user passwords using SHA512 encrypted hashes

Categories // Uncategorized Tags // esxi, prompt, ssh

Comments

  1. Peter Kiel says

    12/30/2013 at 11:09 pm

    With ESXi 5.5 PS1 is '\w \$ ' which is even a much bigger nag as it fills the line with the actual path.
    This leads to a very small input space on the right if you are deeper in the path (e.g. /vmfs/volumes/{datastoreXYZ) and makes it likely to get commands breaking up to another line which is awkward, ugly and shows problems with copy/paste etc.
    I wonder who the crap came up with this lousy idea.
    If I want the path in the prompt I also always add a newline so that I get a clean space to enter my commands. The sacrifice here is an extra prompt line for the sake of a better readability.
    So I either set PS1='\W \$ ' or better yet PS1='\w \n\$ '
    In your case I would go with PS1='\[email protected]\h:\w \n\$ '

    Reply
  2. felipe1982 says

    08/08/2014 at 1:29 am

    I also set TZ variable for my timezone, so cron jobs and my `date` command and file timestamps appear "normal"
    export TZ="AEST-10" Sets my timezone to Australian Eastern GMT+10. Note the minus, not plus, sign.

    Reply
  3. Danniel S says

    07/26/2018 at 12:49 am

    Great Tip!
    was strangling with this when i upgraded the ESXi to version 6 the prompt has changed and i of a java application that was executing failed because of it.
    so i just removed the "\e[0;41m[\[email protected]\h \W]\$ \e[m" that was added to the file /etc/profile.local

    Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • Self-Contained & Automated VMware Cloud Foundation (VCF) deployment using new VLC Holodeck Toolkit 03/29/2023
  • ESXi configstorecli enhancement in vSphere 8.0 Update 1 03/28/2023
  • ESXi on Intel NUC 13 Pro (Arena Canyon) 03/27/2023
  • Quick Tip - Enabling ESXi Coredumps to be stored on USB 03/26/2023
  • How to disable the Efficiency Cores (E-cores) on an Intel NUC? 03/24/2023

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2023