LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 06-09-2009, 04:20 AM   #1
epamuk
Member
 
Registered: May 2007
Posts: 62

Rep: Reputation: 15
How can i prevent ssh connection for a user


Hi,

I have a user name is nicole. I want to prevent ssh connection for this user. How can i prevent ssh connection for this user?

Thanks.
 
Old 06-09-2009, 04:26 AM   #2
noctilucent
Member
 
Registered: Jun 2009
Distribution: slackware
Posts: 123

Rep: Reputation: 25
man sshd_config -> DenyUsers
 
Old 06-09-2009, 05:06 AM   #3
epamuk
Member
 
Registered: May 2007
Posts: 62

Original Poster
Rep: Reputation: 15
Hi,

I am writing "DenyUsers nicole" end of the page then restart sshd service But Now I can do ssh connection with only root user. I am not doing ssh connection with all other users.

I want to prevent only nicole user.



[root@34istlinux ~]# cat /etc/ssh/sshd_config
# $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $

# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.

#Port 22
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication mechanism.
# Depending on your PAM configuration, this may bypass the setting of
# PasswordAuthentication, PermitEmptyPasswords, and
# "PermitRootLogin without-password". If you just want the PAM account and
# session checks to run without PAM authentication, then enable this but set
# ChallengeResponseAuthentication=no
#UsePAM no
UsePAM yes

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no

# no default banner path
#Banner /some/path

# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server

DenyUsers nicole
[root@34istlinuxtest ~]#
 
Old 06-10-2009, 02:33 AM   #4
epamuk
Member
 
Registered: May 2007
Posts: 62

Original Poster
Rep: Reputation: 15
I need help for this problem.

Thanks.
 
Old 06-10-2009, 02:38 AM   #5
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,365
Blog Entries: 6

Rep: Reputation: 51
Code:
echo “AllowUsers adamk tim sean jacob dave” >> /etc/sshd/sshd_config
Joe is not included here which means he is disabled.
 
Old 06-10-2009, 04:09 AM   #6
tsk1979
LQ Newbie
 
Registered: Jun 2009
Posts: 9

Rep: Reputation: 1
your_shadow03, it will work for small number of users.Lets say there are 100 users, and you want to deny 2, how to do that?
That was the OPs question, allow everyone except nicole
 
Old 06-10-2009, 05:03 AM   #7
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,365
Blog Entries: 6

Rep: Reputation: 51
There are two ways:
1.
Code:
DenyUsers badness paula
2.Another useful restriction is to limit the access to members of a specific group with AllowGroups rather than AllowUsers.

You can lock off all system access to anyone not defined as an end-user, and don't have to fiddle with the configuration each time you add a new customer/client to the system to specifically permit them access as all they need is group membership of the permitted end-user group.

Last edited by your_shadow03; 06-10-2009 at 05:06 AM.
 
Old 06-10-2009, 10:09 PM   #8
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Debian, FreeBSD
Posts: 3,559
Blog Entries: 3

Rep: Reputation: Disabled
Quote:
Originally Posted by epamuk
I have a user name is nicole. I want to prevent ssh connection for this user. How can i prevent ssh connection for this user?
What distro is this? If Red Hat-family, put the DenyUsers directive back into place, and tail the /var/log/secure file while attempting to login over ssh as another user (not nicole).

Post the results here.
 
Old 06-11-2009, 04:16 PM   #9
epamuk
Member
 
Registered: May 2007
Posts: 62

Original Poster
Rep: Reputation: 15
Hi,

I resolved this problem. I wrote

DenyUsers nicole@*

Then start and stop sshd service. And I saw nicole havent ssh connection permission.

Thank you for your helps.
 
  


Reply

Tags
ssh


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I prevent a user from being able to log into ssh? scooper Solaris / OpenSolaris 3 04-08-2009 11:50 AM
Prevent ssh to other machines cizzi Linux - Security 16 01-07-2008 08:29 PM
How to prevent root user from logging into ssh linuxjamil Linux - Server 2 10-08-2007 07:10 PM
Permit number of connection from same user on SSH Panagiotis_IOA Linux - Networking 5 08-03-2007 10:55 AM
How to prevent concurrent user connection accessing squid proxy? suhas! Linux - Server 1 07-12-2007 07:46 AM


All times are GMT -5. The time now is 06:51 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration