1838135 Members
3095 Online
110124 Solutions
New Discussion

How to config the ssh?

 
SOLVED
Go to solution
SHENFENG_1
Occasional Advisor

How to config the ssh?

How to config the ssh?
I find the file--"/opt/ssh/etc/sshd_config".
but I can't find a item about login timeout.
In fact,I just want to refuse the user when he key nothing after login in. How to do it?
help me,thanks!
7 REPLIES 7
Joseph Loo
Honored Contributor
Solution

Re: How to config the ssh?

hi,

do u mean Idle Timeout? if so,

for particular users:
# vi ~/.profile
add the following lines to the end of the file:
TMOUT=60
readonly TMOUT

for all users:
# vi /etc/profile
add the following lines to the end of the file:
TMOUT=60
readonly TMOUT

note that 60 is in seconds.

regards.
(p.s. please remember to assign points.)
what you do not see does not mean you should not believe
SHENFENG_1
Occasional Advisor

Re: How to config the ssh?

hi Joseph Loo
Thank you,I modify the profile.then the ssh user login out 60s later,And the user can get a warning "Shell will time out in 60 seconds".
But I worry about that the modification maybe impact other user,DBA user,etc.This user must always login in the system.In other words,the modification can effect some users and some software,I want to know detail,because the machine is very important!thanks!
Joseph Loo
Honored Contributor

Re: How to config the ssh?

hi,

r u saying u only want some users to have this time-out feature? if so, just edit the .profile of those who requires TMOUT.

regards.
what you do not see does not mean you should not believe
Jan Sladky
Trusted Contributor

Re: How to config the ssh?

hi,

if you placed it into $HOME/.profile you needn't be afraid because setting there is for particular user only.

(for global setting for all users is /etc/profile)

br Jan
GSM, Intelligent Networks, UNIX
Andrew Cowan
Honored Contributor

Re: How to config the ssh?

Remember that if you don't want users to be able to change the setting, then export it as READONLY in "/etc/profile".

You should also note that if a user simply enters: read
at the shell prompt, timeout is disabled.
Sridhar Bhaskarla
Honored Contributor

Re: How to config the ssh?

Hi,

You can do it for few users if you want to by putting a small shell code in /etc/profile ( /etc/csh.login for c-shell users). For ex., create a file called /etc/logins.tmout like the following

user1:60
user2:120
user3:180

Add the following code at the end of your /etc/profile.

ME=$(who am i|awk '{print $1}')
grep -q "^${ME}:" /etc/logins.tmout
if [ $? = 0 ]
then TMOUT=$(grep "^${ME}:" /etc/nologins.tmout}awk '{print $2}')
readonly TMOUT
else
TMOUT=
readonly TMOUT
fi

In the else part above, specify the global timout value that you want to set to rest of the users. If you don't want it, delete that part.

-Sri


You may be disappointed if you fail, but you are doomed if you don't try
SHENFENG_1
Occasional Advisor

Re: How to config the ssh?

hi
In fact,I just want to modify sshd_config to the target.I use "man sshd_config" finded a key item "ClientAliveInterval".I config this file,but inefficacy,how to correct use it,who can help me!
$man sshd_config
Sets a timeout interval in seconds after which if no data has
been received from the client, sshd will send a message through
the encrypted channel to request a response from the client. The
default is 0, indicating that these messages will not be sent to
the client. This option applies to protocol version 2 only.