Prisijungimų apribojimas prie SSH ir FTP

Paprastas ir greitas būdas apriboti prisijungimus prie SSH ir FTP per hosts.allow:

vi /etc/hosts.allow

# Leidžiami IP adresai:
sshd : IP_ADRESAS : allow
sshd : IP_ADRESAS2 : allow
sshd : IP_ADRESAS3 : allow

# Draudžiami visi kiti IP:
sshd : ALL : deny

# Leidžiami IP adresai:
in.proftpd : IP_ADRESAS : allow
in.proftpd : IP_ADRESAS2 : allow
in.proftpd : IP_ADRESAS3 : allow

# Draudžiami visi kiti IP:
in.proftpd : ALL : deny

LSOF – list open files

Šaltinis: http://stackoverflow.com/questions/106234/lsof-survival-guide

To show all networking related to a given port:

lsof -iTCP -i :port
lsof -i :22

To show connections to a specific host, use @host

lsof [email protected]

Show connections based on the host and the port using @host:port lsof [email protected]:22

grepping for LISTEN shows what ports your system is waiting for connections on:

lsof -i| grep LISTEN

Show what a given user has open using -u:

lsof -u daniel

See what files and network connections a command is using with -c

lsof -c syslog-ng

The -p switch lets you see what a given process ID has open, which is good for learning more about unknown processes:

lsof -p 10075

The -t option returns just a PID

lsof -t -c Mail

Using the -t and -c options together you can HUP processes

kill -HUP $(lsof -t -c sshd)

You can also use the -t with -u to kill everything a user has open

kill -9 $(lsof -t -u daniel)

CentOS auto atnaujinimų aktyvavimas

Tam, kad įgalinti CentOS auto atnaujinimus reikalingas paketas “yum-cron”. Paketas diegiamas paprastai su yum paketų valdymo įrankių:

yum install yum-cron

Pagal nutylėjimą “yum-cron” atsisiunčia ir atnaujiną programinę įrangą. “Yum-cron” parametrus galima keisti faile “/etc/sysconfig/yum-cron“. Asmeniškai aš pridėjau pranešimo siuntimą, tai atnaujinama sistema automatiškai:

# by default MAILTO is unset, so crond mails the output by itself
# example:  MAILTO=root
[email protected]

Prieš aktyvuojant auto atnaujinimus būtina žinoti du svarbius dalykus:

1) CentOS paketuose nėra konkrečios informacijos apie tam tikras paketų grupes, kaip pvz. saugumo paketai. Automatinio atnaujinimo metu atnaujinami visi operacinės sistemos paketai.

2) Atsižvelgiant į pirmą punktą, kad atnaujinama bus visą sistema, gali sugriūti kai kurios programos. Dėl to būtina iš anksto “excludinti” jautrius paketus, kad nesugriūtų reikiamų servisų veikimas.

Auto atnaujinimų išjungimas jautriai programinei įrangai

“Išjungti” atnaujinimus tam tikrai programinei įrangai galima yum konfigūraciniame faile (/etc/yum.conf) tiesiog juos “excludinti”:

exclude=kernel* php*

Šiuo atveju atjungę auto atnaujinimus, jų negalėsite atnaujinti ir rankinių būdų su “yum update“. Jeigu norima išjungti tik pati auto atnaujinimą, tai galima padaryti ir pačiame “yum-cron” įrankio konfigūracijoje “/etc/sysconfig/yum-cron” prie parametro “YUM_PARAMETER” prirašant su -x paketo pavadinimą:

YUM_PARAMETER="-x kernel* -x php*"

Viską susikonfigūravę pagal savo poreikius turime aktyvuoti “yum-cron” servisą:

/etc/init.d/yum-cron start

Nepamirštame, kad po rebooto viskas veiktų, padaryti:

# chkconfig yum-cron on

Ir “vuolia” Jūsų sistema, bus visada “up to date” 🙂

FIND + CHMOD

Retkarčiais tenka rekursiškai visiems failams ir direktorijos pakeisti rašymo / skaitymo teises, tam puikiai tinka find + chmod tandemas 🙂

Keičiam “chmod” katalogams:

find . -name '*' -type d -exec chmod 0755 {} \;

Keičiam “chmod” failams:

find . -type f -exec chmod 0644 {} \;

APC (Alternative PHP Cache) diegimas CENTOS 6.x aplinkoje

APC (Alternate PHP Cache) – atvirojo kodo PHP kodo spartintuvas. APC tampa vis plačiau naudojamas ir yra stabilesnis už kitus spartintuvus (pvz.: eAccelerator). Ateityje planuojama, kad APC bus pagal nutylėjimą integruotas į PHP 6 branduolio versiją.

Prieš diegimą turime instaliuoti papildomus reikiamus paketus:

yum install php-pear php-devel httpd-devel pcre-devel gcc make

Continue reading APC (Alternative PHP Cache) diegimas CENTOS 6.x aplinkoje

TELNET imap testas

To quickly test an imap server using telnet use:
telnet server 143
01 LOGIN username password
02 LIST "" *
03 SELECT mailbox

Line 02 shows you all available mailboxes.

To show the information about a mailbox:
04 STATUS mailbox (MESSAGES)
Between () you can place one or more of the following: MESSAGES, UNSEEN, RECENT UIDNEXT UIDVALIDITY

And one of the following commands to view the a message 1 is the first message * is wildcard for all:
05 FETCH 1 ALL # All IMAP headers
05 FETCH 1 FULL # Full headers and body info
05 FETCH 1 BODY # Body
05 FETCH 1 ENVELOPE # Envelope
05 FETCH * FULL # All email

To fully retrieve a message use:
06 UID fetch 1:1 (UID RFC822.SIZE FLAGS BODY.PEEK[])