Operating System - Linux
1827880 Members
1407 Online
109969 Solutions
New Discussion

how to restrict number of users to telnet/ftp servers

 
SOLVED
Go to solution
Maaz
Valued Contributor

how to restrict number of users to telnet/ftp servers

Hi Gurus
I have 10 users account on my FTP and telnet servers. I just want to allow 5 users to connect the servers at a time, i.e if 5 users are already connected to the telent/ftp server, then no new connection will be build... what shold I do... help please

I m using rhl 9.

Best Regards
Maaz


4 REPLIES 4
Mark Grant
Honored Contributor
Solution

Re: how to restrict number of users to telnet/ftp servers

Number of "ftp" clients can generally be set in the config file for which ever of the ftp daemons you happen to be running.

Restricting the number of telnets is going to be a bit more annoying.

Here's one option.

put somthing like this in /etc/profile

[ `ps -ef | grep -v grep | grep telnet | wc -l` -gt 5 ] && {
echo "maximum nunmber of telnet sessions reached, sorry"
exit;
}

This isn't foolproof but it will get you close.
Never preceed any demonstration with anything more predictive than "watch this"
Karthik S S
Honored Contributor

Re: how to restrict number of users to telnet/ftp servers

You can also try this.

Add this to /etc/profile


#Allows the root user always
#Only allows once instance of a user login

user=`whoami`
usercount=`who| grep -v root | wc -l`
userinstances=`who| grep $user |wc -l`

if [ $user != root ]
then
if [ $userinstances -gt 1 ]
then
exit
fi
else
if [ $usercount -gt 7 ]
then
exit
fi
fi


-Karthik S S
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Alexander Chuzhoy
Honored Contributor

Re: how to restrict number of users to telnet/ftp servers

since telnet is xinetd based service by default (in older version of redhat so was the ftp service.)
Edit the file /etc/xinetd.conf and add a line:
instances = 3

if you want to limit the xinetd services up to 3 simultanious logins.
As for the ftp- vsftpd which comes today as the default ftp server is not a part of xinetd services.
For vsftpd (the fedault ftp server in redhat) add a line to /etc/vsftpd/vsftpd.conf
max_clients with a number of maximum clients.
Maaz
Valued Contributor

Re: how to restrict number of users to telnet/ftp servers

I really appreciate ... u all are gr8.

Big Help.. Mark Grant, Many Thanks

Karthik S S, I just dont how can I give u 100 points, for ur reply. Really Big help. Many Thanks... Thanks a Million

and Alexander.. is always Gr8


Best Regards
Maaz