Está en la página 1de 34

Chkconfig

Administrador de Linux
“Linux en un entorno real”
Linux en un entorno real

Contenido

LINUX aplicado en un entorno real ....................................................................................................... 3


Configurar lo de redes .............................................................................................................................. 3
Ver estatus de ip .......................................................................................................................................... 3
¿Como hacer upgrade? ............................................................................................................................... 7
Instalar un sistema de web browsing para CLI ........................................................................................ 7
Ambiente de trabajo ................................................................................................................................. 8
Crear llave .................................................................................................................................................... 8
Instalar Apache Server ............................................................................................................................10
Instalar PHP...............................................................................................................................................12
Instalar Base De Datos ............................................................................................................................12
Instalar y Configurar SSH Server. ........................................................................................................13
Instalar GCC ...............................................................................................................................................14
Instalar Java ..............................................................................................................................................15
Instalar TOMCAT para HTTP Java ........................................................................................................16
Instalar NMAP ...........................................................................................................................................17
Configuracion de firewall ......................................................................................................................18
Instalar WGET ...........................................................................................................................................27
TELNET ........................................................................................................................................................28
Instalar WEBMIN ......................................................................................................................................28
Instalar un compresor de archivos ......................................................................................................29
Instalar un servidor FTP .........................................................................................................................31
Configurar SUDO ....................................................................................................................................31
Instalar Rockit Hunter ............................................................................................................................32

2
Linux en un entorno real

LINUX aplicado en un entorno real

Configurar lo de redes

# yum install net-tools [Provides ifconfig utility]

Ver estatus de ip

# ip addr show

3
Linux en un entorno real

Para editar las tarjetas

# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

Detalles

IPADDR = “[Enter your static IP here]”

GATEWAY = “[Enter your Default Gateway]”

DNS1 = “[Your Domain Name System 1]”

DNS2 = “[Your Domain Name System 2]”

# service network restart

Reiniciar Servicio de redes

4
Linux en un entorno real

Checar el status de las redes

Cambiarle el nombre a tu terminal


# echo $HOSTNAME

5
Linux en un entorno real

Check System Hostname


# vi /etc/hostname

Set System Hostname

$ echo $HOSTNAME

6
Linux en un entorno real

Confirmar modificacion

Podrías usar el comando hostname

$ hostname

¿Como hacer upgrade?

# yum update && yum upgrade

Hacer una actualización

Instalar un sistema de web browsing para CLI

# yum install links

7
Linux en un entorno real

Links: Commandline Web Browsing

Ambiente de trabajo

SSH Client : 192.168.0.12 ( Fedora 21 )

SSH Remote Host : 192.168.0.11 ( CentOS 7 )

Crear llave

[tecmint@tecmint.com ~]$ ssh-keygen -t rsa


Generating public/private rsa key pair.
Enter file in which to save the key (/home/tecmint/.ssh/id_rsa): [Press enter key]
Created directory '/home/tecmint/.ssh'.
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Press enter key]
Your identification has been saved in /home/tecmint/.ssh/id_rsa.
Your public key has been saved in /home/tecmint/.ssh/id_rsa.pub.
The key fingerprint is:
5f:ad:40:00:8a:d1:9b:99:b3:b0:f8:08:99:c3:ed:d3 tecmint@tecmint.com
The key's randomart image is:
+--[ RSA 2048]----+
| ..oooE.++|
| o. o.o |
| .. . |
| o . . o|

8
Linux en un entorno real

| S. .+|
| . . . o|
| . o o ..|
| ++ |
| +. |
+-----------------+

Crear llave RSA


Creación de un directorio .SSH

[tecmint@tecmint ~]$ ssh sheena@192.168.0.11 mkdir -p .ssh

The authenticity of host '192.168.0.11 (192.168.0.11)' can't be established.

RSA key fingerprint is 45:0e:28:11:d6:81:62:16:04:3f:db:38:02:la:22:4e.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.0.11' (ECDSA) to the list of known hosts.

sheena@192.168.0.11's password: [Enter Your Password Here]

Subir llave publica generada

[tecmint@tecmint ~]$ cat .ssh/id_rsa.pub | ssh sheena@192.168.0.11 'cat >> .ssh/authorized_keys'

sheena@192.168.1.2's password: [Enter Your Password Here]

Cambia permisos

[tecmint@tecmint ~]$ ssh sheena@192.168.0.11 "chmod 700 .ssh; chmod 640


.ssh/authorized_keys"

9
Linux en un entorno real

sheena@192.168.0.11's password: [Enter Your Password Here]

Instalar Apache Server

# yum install httpd

Si quieres cambiar cosas del servidor

Debes editar este archivo

‘/etc/httpd/conf/httpd.conf‘

10
Linux en un entorno real

Permitir http a través del firewall


# firewall-cmd --add-service=http
Permite el puerto 3221
# firewall-cmd -permanent -add-port=3221/tcp
Recarga el firewall
# firewall-cmd --reload
Reiniciar Apache
# systemctl restart httpd.service
# systemctl start httpd.service
# systemctl enable httpd.service
Verificar con link
# links 127.0.0.1

11
Linux en un entorno real

Instalar PHP

# yum install php


Reiniciar Apache
# systemctl restart httpd.service
Verificar php
# echo -e "<?php\nphpinfo();\n?>" > /var/www/html/phpinfo.php

Instalar Base De Datos

# yum install mariadb-server mariad

Configurar mariaDB

# systemctl start mariadb.service

# systemctl enable mariadb.service

Permitir el servicio por el firewall

# firewall-cmd --add-service=mysql

# /usr/bin/mysql_secure_installation

12
Linux en un entorno real

Seguridad de MariaDB

Instalar y Configurar SSH Server.

# SSH -V

CHECAR ssh version

13
Linux en un entorno real

Modificar la configuración de ssh


file ‘/etc/ssh/ssh_config‘.
Activar más seguridad en el protocolo ssh
# Protocol 2,1 (Original)
Protocol 2 (Now)
Desactivamos el puerto 22, y lo cambiamos a cualquier otro.
Instalar GCC

# yum install gcc

Checamos la versión
# gcc --version

14
Linux en un entorno real

Instalar Java

# yum install java

Instalando java
Checar versión

# java -version

15
Linux en un entorno real

Instalar TOMCAT para HTTP Java

# yum install tomcat

# systemctl start tomcat

Versión de tomcat

# /usr/sbin/tomcat versión

Check Tomcat Versión


Decirle al firewall el puerto de tomcat

# firewall-cmd --zone=public --add-port=8080/tcp --permanent

# firewall-cmd --reload

Editamos este archivo ‘/etc/tomcat/tomcat-users.xml‘. Para crear un usuario y una contraseña

<tomcat-users>

....

</tomcat-users>

<role rolename="manager-gui"/>

<role rolename="manager-script"/>

<role rolename="manager-jmx"/>

<role rolename="manager-status"/>

16
Linux en un entorno real

<role rolename="admin-gui"/>

<role rolename="admin-script"/>

<user username="tecmint" password="tecmint" roles="manager-gui,manager-script,manager-


jmx,manager-status,admin-gui,admin-script"/>

</tomcat-users>

Secure Tomcat

Aquí paramos y reiniciamos el servicio

# systemctl stop tomcat

# systemctl start tomcat

# systemctl enable tomcat.service

Instalar NMAP

Sirve para monitorear puertos y q servicios están en el

# yum install nmap

En una dirección q puertos están disponibles

# nmap 127.0.01

17
Linux en un entorno real

También por medio de firewalls

# firewall-cmd --list-ports

Configuracion de firewall

# systemctl status firewalld

OR

# firewall-cmd –state

18
Linux en un entorno real

También se pueden checar por zonas

# firewall-cmd --zone=work --list-all

Checar la zona por defecto

# firewall-cmd --get-default-zone

19
Linux en un entorno real

Cambiar a Zona de trabajo

# firewall-cmd --set-default-zone=work

Enlistar todas las zonas

# firewall-cmd --list-services

20
Linux en un entorno real

Agregar servicios temporales

# firewall-cmd --add-service=http

# firewall-cmd –reload

21
Linux en un entorno real

Agregar servicios permanentes

# firewall-cmd --add-service=http --permanent

# firewall-cmd --reload

Remover servicios temporales

# firewall-cmd --remove-service=http

# firewall-cmd --reload

22
Linux en un entorno real

Remover servicios permanentes

# firewall-cmd --zone=work --remove-service=http --permanent

# firewall-cmd --reload

Remove Service Permanently

Para agregar puertos temporales

23
Linux en un entorno real

# firewall-cmd --add-port=331/tcp

# firewall-cmd –reload

Para agregar puertos permanentes

# firewall-cmd --add-port=331/tcp --permanent

# firewall-cmd --reload

Bloquear o remover puertos temporales

# firewall-cmd --remove-port=331/tcp

# firewall-cmd --reload

24
Linux en un entorno real

Bloquear o remover puertos permanentes

# firewall-cmd --remove-port=331/tcp --permanent

# firewall-cmd –reload

Para desactivar firewall

# systemctl stop firewalld

25
Linux en un entorno real

# systemctl disable firewalld

# firewall-cmd --state

Para activar firewall

# systemctl enable firewalld

# systemctl start firewalld

# firewall-cmd –state

26
Linux en un entorno real

Instalar WGET

Esta herramienta sirve para descargar archivos de protocolos de internet

# yum install wget

27
Linux en un entorno real

TELNET

Nos permite comunicarnos a otras computadoras

# yum install telnet

# telnet google.com 80

Instalar WEBMIN

Nos sirve para configurar un sistema en línea de gestión de Linux pudiendo


manejar prácticamente todo lo q tenemos ahí por medio de una interfaz web
# wget http://prdownloads.sourceforge.net/webadmin/webmin-1.740-1.noarch.rpm

# rpm -ivh webmin-*.rpm

Agregar Repositorios de otras partes


Recuerden que es muy riesgoso hacer este tipo de cosas en un sistema de
servidores en producción
# yum install epel-release
Agregar una comunidad de repositorio Linux.

28
Linux en un entorno real

# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

Instalar un compresor de archivos

# yum install p7zip

29
Linux en un entorno real

Instalar NTFS adaptador


# yum install ntfs-3g

Para instalar dispositivos


# mount -ro ntfs-3g /dev/sda5 /mnt

# cd /mnt

# ls -l

30
Linux en un entorno real

Instalar un servidor FTP

# yum install vsftpd

Configurar con VI
# vi /etc/vsftpd/vsftpd.conf

Dejar configurado estas características


anonymous_enable=NO

local_enable=YES

write_enable=YES

chroot_local_user=YES

cambiar el puerto de servicio en el firewall


# firewall-cmd --add-port=21/tcp

# firewall-cmd --reload
Después iniciar ftp

# systemctl restart vsftpd

# systemctl enable vsftpd

Configurar SUDO

# visudo

Abrirá el siguiente archivo

31
Linux en un entorno real

/etc/sudoers

Darle todo los permisos a un usuario, a excepción de reinicio y apagado

tecmint ALL=(ALL) ALL

volver a abrir y ahora hacer lo siguiente en el mismo archivo

cmnd_Alias nopermit = /sbin/shutdown, /sbin/reboot

después agregar alias con operadores lógicos ¡

cmnd_Alias nopermit = /sbin/shutdown, /sbin/reboot

darle permisos a un grupo para correr algunos pocos comandos

cmnd_Alias permit = /usr/sbin/useradd, /usr/sbin/userdel

y al final agregar permisos al grupo debían

debian ALL=(ALL) permit

Instalar Rockit Hunter

# yum install rkhunter

32
Linux en un entorno real

Y veremos algo así


# rkhunter --check

Scan for rootkits

33
Linux en un entorno real

RootKit Scan Results

34

También podría gustarte