Translate

martes, octubre 20, 2020

Systemd – Configuración de servicios en RHEL7




Creamos el script del servicio que lanzará el servicio de jboss

vim /etc/systemd/system/jboss.service 


Agregamos el siguiente contenido:

[Unit]

Description=servicio Jboss

After=network.target

[Service]

ExecStart=/bin/bash /opt/jboss/bin/jboss.sh start

ExecStop=/bin/bash /opt/opt/jboss/bin/jboss.sh stop

Type=forking

#PIDFile=/app/puerto53/httpd/run/httpd/httpd.pid

[Install]

WantedBy=multi-user.target


Ejecutamos los siguiente comandos para activar dicho servicio.

*cargamos todos los servicios de nuevo:
sudo systemctl daemon-reload
*activamos nuestro servicio nuevo para que funcione en el reboot del S.O (jboss):
sudo systemctl enable jboss.service
*Podemos lanzar el servico
sudo systemctl start jboss
*ahora podemos comprobar el estado del servico:
sudo systemctl status jboss


nota:
Para los sistemas actuales de jboss:
Copiar el scrip en una carpeta con extension .sh, ponemos en el inicio del scrip el siguiente la siguente linea
#!/bin/bash


 cp /etc/init.d/jboss /opt/jboss/bin/jboss.sh

viernes, octubre 16, 2020

Acceder por 4G/3G/2G a tu smartphone Android por SSH proxy inverso con bitcoinshell

Para realizar el proceso usando la app userlanz corriendo un ubuntu debajo del android:

Instalar en shell smartphone android sshpass:

sudo apt install sshpass

Script a ejecutar en la shell del smartphone,:

#!/bin/bash

REMOTE_PORT=22

REMOTE_ADDRESS=usr_bitcoinshell@bitcoinshell.mooo.com

PASSWORD="password_de_usr_bitcoinshell"


sshpass -p "$PASSWORD" \

ssh -o ServerAliveInterval=60 \

    -o ServerAliveCountMax=2 \

    -o StrictHostKeyChecking=no \

    -o UserKnownHostsFile=/dev/null \

    -o ConnectTimeout=15 \

    -N -R 2222:localhost:22 $REMOTE_ADDRESS -p $REMOTE_PORT


Comando para acceder desde ssh desde bitcoinshell


ssh usr_shellAndroid@localhost -p 2222



NOTA, simplificando: en android usando la app termux, el servidor ssh corre en el puerto 8022, desde termux instalar sshpass (apt install sshpass)el script para usarlo con termux queda asi:

Tenemos que ver que usuario esta corriendo en termux ssh, usando whoami y aplicamos contraseña con passwd

#!/bin/bash

REMOTE_PORT=22

REMOTE_ADDRESS=usrbitcoinshell@bitcoinshell.mooo.com

PASSWORD="passusrbitcoinshell"

sshpass -p $PASSWORD \

ssh -o ServerAliveInterval=60 \

    -o ServerAliveCountMax=2 \

    -o StrictHostKeyChecking=no \

    -o UserKnownHostsFile=/dev/null \

    -o ConnectTimeout=15 \

-N -R 2222:localhost:8022 $REMOTE_ADDRESS -p $REMOTE_PORT



Desde la shell de bitcoinshell:
ssh usrTermux@localhost -p 2222


viernes, octubre 09, 2020

Como incluir un equpo RedHAt/centroen 7.x en monitorizacion nagios con smnp rapidamente

 

Monitorización – Nagios

 

Montar DVD como root:

 

Instalamos los paquetes necesarios desde /media/Packages

rpm -vih net-snmp-agent-libs-5.7.2-28.el7.x86_64.rpm

rpm -vih net-snmp-5.7.2-28.el7.x86_64.rpm

 

Hacemos backup del siguiente fichero:

mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.old

y lo editamos y pegamos el siguiente contenido:

nano /etc/snmp/snmpd.conf

 

com2sec readonly  172.16.44.6      public

 

group MyROSystem v1        paranoid

group MyROSystem v2c       paranoid

group MyROSystem usm       paranoid

group MyROGroup v1         readonly

group MyROGroup v2c        readonly

group MyROGroup usm        readonly

group MyRWGroup v1         readwrite

group MyRWGroup v2c        readwrite

group MyRWGroup usm        readwrite

 

view all    included  .1                               80

view system included  .iso.org.dod.internet.mgmt.mib-2.system

 

access MyROSystem ""     any       noauth    exact  system none   none

access MyROGroup ""      any       noauth    exact  all    none   none

access MyRWGroup ""      any       noauth    exact  all    all    none

 

syslocation Unknown (edit /etc/snmp/snmpd.conf)

syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)

 

master  agentx

 

Lanzamos el srvicio snmpd como root:

 

 service snmpd start

 

Deshabilitamos el firewall:

systemctl disable firewalld

 

 

Comprobamos que ya llegan las trazas snmp desde el servidor a monitorizar, desde el servidor vmonitor lanzamos este comando:

 

snmpwalk -v 2c -c public jboss03des system

 

Tiene que dar una respuesta como esta:

 


 

 

Alta de jboss03des en Centreon:

 

Entramos en Centreon

 


Vamos a Configuration à hostà add


 

 

Dejar tal cual aparece en esta captura de pantalla y dar a botón save:


 

Ir a configuration à Nagios

Seleccionar las casillas “move Expor Files” y “Restart Nagios” y dar a boton Export


 

Entramos en Nagios y tras una búsqueda del host jboss03des vemos que ha empezado la monitorización:

 


Configurar samba smb en entronos RedHat / centos version 7.X 8.X ... 2020

 

What is Samba

To provide printer and file sharing, Microsoft Windows uses a facility known as SMB (Server Message Block). This same facility is sometimes known as NetBIOS or LanManager. Thanks to Andrew Tridgell and others, Linux systems provide support for SMB via a package known as Samba. Like SMB, Samba lets you:

  • Share printers and files among Microsoft Windows, OS/2, Netware, and Unix systems
  • Establish a simple nameserver for identifying systems on your local area network
  • Backup PC files to a Linux system and restore them
  • Administer users and passwords

Samba has proven its reliability and high performance in many organizations.Samba software suite on Enterprise Linux is a collection of programs that implements the Server Message Block (commonly abbreviated as SMB) protocol for UNIX systems.

Installing Samba

In Enterprise Linux system, install below packages to get started with Samba. You can download/install these packages from yum server using the “yum install” command.

samba       #### basic Samba packages
samba-client       #### samba client

To install these packages :

# yum install samba
# yum install samba-client

If you are using an active directory setup, install below packages as well.

# yum install samba-winbind
# yum install samba-winbind-clients
# yum install samba-winbind-krb5-locator

Below are the list of packages which will be installed once you have installed the above packages.

samba-libs
samba-winbind-krb5-locator
samba-winbind-modules
samba-vfs-glusterfs
samba-winbind
samba-client
samba-common
samba-winbind-clients
samba

Configuring a Samba share

Samba’s configuration usually resides in /etc/samba/smb.conf which contains all the configuration parameters related to samba. Follow the steps given below to configure a samba share.

1. For the share to be accessible to a particular user, we must first create a user (john) on the linux server where the share resides as well.

# useradd john
# passwd john
Changing password for user john.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

2. To add activate the Samba user and set the password, use the “smbpasswd” command with the -a option.

# smbpasswd -a john

3. Create the directory to share or you can use an existing directory. Also set full permissions on the directory.

# mkdir -p  /path/to/share
# chmod -R 777 /path/to/share

4. Next, set the SElinux contexts on the share. Verify if you can create a file in the share.

# chcon -R -t samba_share_t /path/to/share
# cd /path/to/share
# echo test > testfile.txt

5. Edit the /etc/samba/smb.conf file and add the share settings.

# vi /etc/samba/smb.conf
[share_name]
    path = /path/to/share
    comment = samba share for john
    public = yes
    writable = yes
    create mask = 0777
    browseable = yes

Restart samba service for the above settings to take effect.

# service smb restart

To enable the service so that it survives a reboot execute the following:

systemctl enable smb


Troubleshooting

To find out the issue with a samba share, you can try disabling the iptables service and turning off the SELinux. Make sure to enable them back after you resolve the confilct.

# service iptables stop
# setenforce 0

Verify samba parameter using testparm
To verify that the parameters are correct in the smb.conf file or to debug configuration problems, use the testparm command.

logs
For debugging problems with Samba in general, the log files log.smbd and log.nmbd under the /var/log/samba directory are invaluable. The parameter log level in the global section of the smb.conf file determines the amount of detailed information Samba writes to the log files, with level 0 being the most general and 10 being the most detailed. Each logging level contains the messages from that level, in addition to the logging messages below it. For example, a logging level of 5 contains messages from level 5, plus those from levels 0 through 4.

# vi /etc/samba/smb.conf
# this tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/%m.log
debuglevel = 4