0

With our latest hardware/OS refresh, we implemented FQDN throughout our domain. We are now having a problem getting the correct prompt in our terminal sessions when we ssh into a remote site. This wouldn't be a problem except that we are often ssh'd into multiple sites and all the prompts are identical no matter which site we are connected to. Before implementing FQDN, we previously set the hostname of each sites gateway server to the sitename (site1, site2, etc...) and thus the login prompt allowed us to recognize which site we were connected to in each remote terminal session.

Now with RHEL 7 utilizing FQDN this is our hostname:

user1@site1:/home/user1
# hostnamectl status
   Static hostname: gwsrv.site1.system.division.company.com
   Pretty hostname: site1
         Icon name: computer-server
           Chassis: server
        Machine ID: 988c77c116d744fb8b26629aab7beace
           Boot ID: b56bd8e144924560a9051dafbd2ac867
  Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
       CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
            Kernel: Linux 3.10.0-514.el7.x86_64
      Architecture: x86-64

We modified the prompt using /etc/profile.d/profile.sh and it formats the prompt as expected:

PS1=`/usr/bin/whoami`@`/usr/bin/hostnamectl --pretty`:'$PWD
# '

Which returns the prompt:

user1@site1:/home/user1
# 

And if I elevate myself to root I get the same prompt:

user1@site1:/home/user1
# su
Password:
root@site1:/home/user1
#

But, if I change to any other users I get a different prompt:

user1@site1:/home/user1
# su user2
Password:
[user2@gwsrv user1]$

It doesn't matter if I ssh in as any other user, my prompt for all users, except for user1 and root, give me this same prompt:

[user#@gwsrv ~]$

What file and which line do I need to modify to change this other prompt to resemble the prompt for user1 and root:

[user#@site1 ~]$

Specifically we need it to show that they are logged into the site not the gwsrv.

Thank you for your assistance.

  • 2
    Is your PS1 assignment being overriden by a ~/.bash_profile, ~/.bash_login, or ~/.profile in the offending users' $HOME? – Kevin Kruse May 17 '18 at 17:40
2

Configurations in /etc/profile can (and often will) be overridden by a user's own settings in their home directories (e. g. ~/.bash_profile). Short of somehow implementing a regime that prevents a user from setting PS1 within their own environment, there's not really a way you can mandate a user has a specific prompt.

You could do something like grep 'PS1=' /home/*/.* to find the likely candidates that change things, but that will not necessarily be exhaustive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.