Operating System - HP-UX
1826004 Members
3430 Online
109690 Solutions
New Discussion

How to display hostname when a user tries to login using ssh

 
SOLVED
Go to solution
santosh jha
Frequent Advisor

How to display hostname when a user tries to login using ssh

Hey Guys ,

I want to display hostname when a user tries loggin to a system using ssh.

Please guide me how to achieve that.

I have already put an entry in the /etc/issue

Regards
Santosh Jha
6 REPLIES 6
Arunvijai_4
Honored Contributor

Re: How to display hostname when a user tries to login using ssh

Hi,

You can use, # who -T |awk '{print $9}' will print hostname.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
santosh jha
Frequent Advisor

Re: How to display hostname when a user tries to login using ssh

Arun ,

I want to put an entry in the /etc/issue

banner `hostname` and i want that the banner of hostname should be displayed when a user tries to loging using ssh.
Arunvijai_4
Honored Contributor

Re: How to display hostname when a user tries to login using ssh

Hi Santhosh,

Instead of putting into /etc/issue, try to put in /etc/profile

----/etc/profile----
..................
..................
# Leave defaults in user environment.

trap 1 2 3
banner `hostname`

Save and quit. when you login next time, you will see the banner.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
santosh jha
Frequent Advisor

Re: How to display hostname when a user tries to login using ssh

If you put the entry in /etc/profile the banner is display after you entre your username and passwd ..where as i want it to display the banner before that.

Thx
Arunvijai_4
Honored Contributor
Solution

Re: How to display hostname when a user tries to login using ssh

Hi Again,

Check /opt/ssh/etc/sshd-config for # no default banner path
#Banner /some/path

You can edit this and put your own. After doing any modification, remember to restart Secure shell daemon.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
rariasn
Honored Contributor

Re: How to display hostname when a user tries to login using ssh

Hi Santosh,

In /etc/profile,

# Security message fro SSH login


if [ "$SSH_CLIENT" != "" ]
then
echo '$(hostname -a)
cat /etc/issue.ssh
fi
Sample /etc/issue,

This system is for the use of authorized users only. Individuals using this computer system without authority, or in excess of their authority, are subject to having all of their activities on this system monitored and recorded by system personnel...