Tuesday, August 30, 2022

Audit a las autenticaciones

con estos comandos podemos visualizar que usuarios han intentado ingresar a la maquina

#funciona hast debian buster

cat /var/log/auth* | grep Failed


cat /var/log/auth* | grep Accepted

audit.sh


Para bookworm Debian 12

#https://serverfault.com/questions/1148725/where-is-some-os-logs-in-debian-12

journalctl --since "1 hour ago" | grep Accepted*

journalctl --since "1 hour ago" | grep Failed*


Ejemplo:  sshd[178606]: Accepted password for pi from 192.168.1.105 port 58964 ssh2



Saturday, July 9, 2022

correo plano python - Sending Emails in Python With SMTP

 https://code.tutsplus.com/tutorials/sending-emails-in-python-with-smtp--cms-29975

# import necessary packages

  

from email.mime.multipart import MIMEMultipart

from email.mime.text import MIMEText

import smtplib

  

# create message object instance

msg = MIMEMultipart()

  

  

message = "Thank you"

  

# setup the parameters of the message

password = "your_password"

msg['From'] = "your_address"

msg['To'] = "to_address"

msg['Subject'] = "Subscription"

  

# add in the message body

msg.attach(MIMEText(message, 'plain'))

  

#create server

server = smtplib.SMTP('smtp.gmail.com: 587')

  

server.starttls()

  

# Login Credentials for sending the mail

server.login(msg['From'], password)

  

  

# send the message via the server.

server.sendmail(msg['From'], msg['To'], msg.as_string())

  

server.quit()

  

print("successfully sent email to %s:" % (msg['To']))

Temp - stress rpi4 fanless

 https://community.element14.com/products/roadtest/b/blog/posts/raspberry-pi-4-model-b-review

sudo apt-get install stress

sudo stress --cpu 4

watch -n 1 /opt/vc/bin/vcgencmd measure_temp

Thursday, June 30, 2022

Clear Jenkins build history ( clear build yesterday )

Go to Jenkins Script Console.

Go to your Jenkins home page -> Manage Jenkins -> Script Console.

def jobName = "Nombre del job a limpiar"

def job = Jenkins.instance.getItem(jobName)  

job.getBuilds().each { it.delete() }  

job.nextBuildNumber = 1   

job.save()


https://superuser.com/questions/1418885/clear-jenkins-build-history-clear-build-yesterday#:~:text=Delete%20a%20Jenkins%20build%20via,script%20in%20Jenkins%20Script%20Console.

Tuesday, May 31, 2022

memoria disponible en servidor SQL

 SELECT

(total_physical_memory_kb/1024) AS Total_OS_Memory_MB,

(available_physical_memory_kb/1024)  AS Available_OS_Memory_MB

FROM sys.dm_os_sys_memory;


SELECT  

(physical_memory_in_use_kb/1024) AS Memory_used_by_Sqlserver_MB,  

(locked_page_allocations_kb/1024) AS Locked_pages_used_by_Sqlserver_MB,  

(total_virtual_address_space_kb/1024) AS Total_VAS_in_MB,

process_physical_memory_low,  

process_virtual_memory_low  

FROM sys.dm_os_process_memory; 


select getdate() as fecha_y_Hora_Actual


salida.







System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send

Solucion - forzar TLS 1.2

 var securityProtocol = (int)System.Net.ServicePointManager.SecurityProtocol;

                // 0 = SystemDefault in .NET 4.7+

                if (securityProtocol != 0)

                {

                    Log.Info(securityProtocol);

                    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

                    Log.Info("allocated Security Protocal: " + ServicePointManager.SecurityProtocol);

                }


System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)

   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)

   --- End of inner exception stack trace ---

   at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)

   at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)

   at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)

   --- End of inner exception stack trace ---

   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)

   --- End of inner exception stack trace ---

   --- End of inner exception stack trace ---

   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)

   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)

   at System.Threading.Tasks.Task`1.get_Result()



System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)

   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)

   --- End of inner exception stack trace ---

   at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)

   at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)

   at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)

   --- End of inner exception stack trace ---

   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)

   --- End of inner exception stack trace ---<---

Sunday, May 8, 2022

RAM zram-tools

 

#basado en https://www.muylinux.com/2021/01/29/swap-zram-debian-ubuntu/

sudo apt install zram-tools

sudo nano /etc/default/zramswap

PERCENTAGE=50


#borrar la particion de swap

sudo nano /etc/fstab 

#para desactivar la particion de swap

sudo dphys-swapfile swapoff