Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linux security 1

Status
Not open for further replies.

7280

MIS
Apr 29, 2003
331
IT
Hi,
I need to implement security on my linux servers (all redhat el as, versions 3 and 4).
First of all I have to setup a password management policy, so password should expire every month, password length is 8 characters, minimum 2 alpanumeric, and so on..
root user can login only on console, not remotely.
These are the most important to start with.

After that I want to disable unneeded services, is there any security guide to follow?

Thanks in advance
 
to set password minimal length to 8 edit the file

/etc/default/passwd

if you do not find a valid option there add the following

PASSLENGTH=8

The passwd utility also allows you to set number of days before the user is asked for a password.

passwd -x 30 mike

will set the new password for user mike and set its validity to 30 days.



to prevent root user from logging in remotely edit the file

/etc/ssh/sshd.conf

add the following directive

PermitRootLogin no


Cheers

QatQat

Life is what happens when you are making other plans.
 
Apologies,

the file to edit to prevent root login is

/etc/ssh/sshd_config


QatQat

Life is what happens when you are making other plans.
 
thanks, is it possible to set the number of days for all users, even the new one created without issuing command passwd -x 30 username?

thanks again
 
try adding

MAXWEEKS=4

to your /etc/default/passwd file


QatQat

Life is what happens when you are making other plans.
 
You can change the 5th field in /etc/shadow to "30". I think that the -x option works without requiring a password change (at least it did when I just tried it on a test account). You could do something like this:

for u in `awk -F: '{ print $1 }' /etc/passwd`; do passwd -x 30 $u; done
 
Haven't read it thoroughly, but it will probably get you into the right ballpark:


As far as disabling services in RedHat specifically, this should be helpful, assuming you understand what a service is by its name:


Remember, nmap is your friend when verifying a closed or filtered port.


pansophic
 
That is the problem.
I have lot of services and don't know what they are!

acpid 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
anacron 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
arptables_jf 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
atd 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
autofs 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
cpuspeed 0:eek:ff 1:eek:n 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
crond 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
cups 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
cups-config-daemon 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
dkms_autoinstaller 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
gpm 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
haldaemon 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
iptables 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
irqbalance 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
isdn 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
kudzu 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
lm_sensors 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
mdmonitor 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
messagebus 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
microcode_ctl 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
netfs 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
network 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
nfslock 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
ntpd 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:ff 5:eek:n 6:eek:ff
pcmcia 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
portmap 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
rawdevices 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
readahead 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:ff 4:eek:ff 5:eek:n 6:eek:ff
readahead_early 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:ff 4:eek:ff 5:eek:n 6:eek:ff
rhnsd 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
rpcgssd 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
rpcidmapd 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
sendmail 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
smartd 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
sshd 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
syslog 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
sysstat 0:eek:ff 1:eek:n 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
xfs 0:eek:ff 1:eek:ff 2:eek:n 3:eek:n 4:eek:n 5:eek:n 6:eek:ff
xinetd 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:n 4:eek:n 5:eek:n 6:eek:ff

file /etc/inetd.conf doesn't exist, what is the corresponding file in redhat?

Last thing, if I do nmap on that server I see:
(The 1657 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
1720/tcp open H.323/Q.931

Does this mean that I have only those 3 ports open?
Can I disable rpcbind? H.323 is voip right?

Thanks again.
 
Well, where to start, normally f you google each of these daemons you will find a lot of info.

You could kill all hardware recognition and software /hardware communication packages if your system is in production and you are not changin git anymore

kudzu
haldaemon

you can kill isdn unless you need it

unless yu are using a desktop system, kill cups and cups config (printers database)

anacron can be disabled if your system will be always on (it is sort of cron daemon for systems that do not run 24/7.

pcmcia, yu know if you need it (if it is not a laptop disable it)

lm_sensors, when you will need it you will find out what it is, for the time being you can disable it

This is just a start; I suggest you google all services you do not know and prevent them from starting at whatever runlevel you work.

Cheers

QatQat





If I could have sex each time I reboot my server, I would definitely prefer Windoz over Linux!
 
portmap is the service that has port 111 (rpcmapper) open. If you turn it off, it will close the port and potentially increase the security of your system. The downside is that services that rely on rpc won't work. So that is things like NIS, NFS, mountd, etc.

So if you are running a standalone server you can safely turn off netfs, portmap, rpcidmapd and rpcgssd.

Other than that only other network accessible protocols you are running are sshd and some H.323 VoIP service. Presumably both of these are required for your application.

It doesn't look like you are using any of the xinetd services, so you should be able to turn that off as well.

But as QatQat says, googling the services is the best way to determine what is and is not critical to your application.


pansophic
 
Hi,
I'm trying to implement password policy as suggested but I'm not finding file /etc/default/passwd.
In /etc/default directory I have only useradd and nss files.
Also I'm having many users that I want to lock or delete:

adm:x:3:4:adm:/var/adm:/sbin/nologin
apache:x:48:48:Apache:/var/bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
desktop:x:80:80:desktop:/var/lib/menu/kde:/sbin/nologin
ftpredactum:x:506:50:Redactum FTP User:/home/ftpredactum:/bin/ftponly
ftpuser:x:504:50::/home/ftpuser:/bin/bash
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin
gfimon:x:514:100:Account per il monitoring di gfi:/home/gfimon:/bin/bash
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
halt:x:7:0:halt:/sbin:/sbin/halt
ident:x:100:101::/home/ident:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
named:x:25:25:Named:/var/named:/sbin/nologin
netdump:x:34:34:Network Crash Dump user:/var/crash:/bin/bash
news:x:9:13:news:/etc/news:
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
operator:x:11:0:eek:perator:/root:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
rpc:x:32:32:portmapper RPC user:/:/sbin/nologin
rpm:x:37:37::/var/lib/rpm:/sbin/nologin
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
squid:x:23:23::/var/spool/squid:/sbin/nologin
sshd:x:74:74:privilege-separated SSH:/var/empty/sshd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
webalizer:x:67:67:Webalizer:/var/xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin

Do I need to lock also users that have /sbin/nologin shell or I don't have to care about them since they can't login?

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top