firmas, problema con ssh-keygen

This commit is contained in:
Sergio Pernas 2022-03-15 14:56:47 -03:00
parent da2f572ed3
commit 14aec95b6f
6 changed files with 19 additions and 28 deletions

View File

@ -7,7 +7,9 @@ fi
# LECTURA FICHERO DE CONFIGURACION
config=/etc/nodemecu.conf
envs=/opt/nodemecu/envs
source $config
source $envs
source $funciones
[ -z $1 ] && exit

View File

@ -1,6 +1,6 @@
#!/bin/bash
source /etc/nodemecu.conf
source /opt/nodemecu/envs
if [ $UID -ne 0 ]; then
echo "Ejecute 'sudo $0'"
exit

View File

@ -8,11 +8,7 @@ get_stack () {
fi
}
# Generar una llave privada ECDSA si no existe
#
# Uso: generate_private_key "comentario"
generate_private_key () {
test -f "$private_key" && return 1
@ -33,7 +29,6 @@ sign_file () {
}
funcion_datos_simulados() {
lecturas="id:dummy_plug-01 tp:temp vl:$(( $RANDOM % 20 + 15 )) un:C er:99 AD_SENSOR tp:hum vl:$(( $RANDOM % 50 + 35 )) un:percent er:99 AD_ARDUINO id:dummy_plug-02 tp:temp vl:$(( $RANDOM % 20 + 15 )) un:C er:99 AD_SENSOR tp:hum vl:$(( $RANDOM % 50 + 35 )) un:percent er:99 AD_ARDUINO id:dummy_plug-03 tp:temp vl:$(( $RANDOM % 20 + 15 )) un:C er:99 AD_SENSOR tp:hum vl:$(( $RANDOM % 50 + 35 )) un:percent er:99 AD_ARDUINO id:dummy_plug-04 tp:temp vl:$(( $RANDOM % 20 + 15 )) un:C er:99 AD_SENSOR tp:hum vl:$(( $RANDOM % 50 + 35 )) un:percent er:99 END"

View File

@ -1,7 +1,7 @@
#!/bin/bash
source /etc/nodemecu.conf
source $env
source /opt/nodemecu/envs
source $funciones
conteo=$(cat $contador)

View File

@ -1,25 +1,18 @@
#!/bin/bash
#set -x
if [ $UID -ne 0 ]; then
echo "Ejecute 'sudo $0'"
exit
fi
basedir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
configuracion=$basedir/nodemecu.conf.ejemplo
envs=$basedir/envs
cat $configuracion
cat $envs
exit
source $configuracion
if [ $UID -ne 0 ]; then
echo "Ejecute 'sudo $0'"
exit
fi
source $envs
if [ -d $directorio_instalacion ] ; then
echo "nodemecu ya se encuentra instalado"
@ -27,15 +20,14 @@ if [ -d $directorio_instalacion ] ; then
fi
ficheros="bin env arduinos.py contador generador_json funciones monitor monitor_web registrador desinstalar"
ficheros="bin envs arduinos.py contador generador_json funciones monitor monitor_web registrador desinstalar"
# Dependencias
echo "1. Instalando dependencias
"
apt update && apt install -y python3-pip jsonlint jq uuid
pip3 install pyserial
#apt update && apt install -y python3-pip jsonlint jq uuid
#pip3 install pyserial
echo ""
@ -81,7 +73,7 @@ echo "
sn=$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2)
sed -i 's/numero_serie=/numero_serie/' $env
sed -i 's/numero_serie=/numero_serie='$sn'/' $directorio_instalacion/envs
echo "Número de serie: $sn"

View File

@ -1,5 +1,7 @@
#!/bin/bash
set -x
source /etc/nodemecu.conf
source /opt/nodemecu/envs
source $funciones
@ -38,18 +40,18 @@ while :;do
#fi
# firma de registros
sign_file $registros/$file
firma="$(cat $registros/$file.sign)"
sign_file $registros/$file
exit
local_transaction_uuid=$(jq -r '."transaction_uuid"' $registros/$file)
remote_transaction=$(curl -s --connect-timeout 1,5 --show-error -w "~%{http_code}" -X POST -H "X-Signature: $firma" -H "Content-Type: application/json" -d @$registros/$file $servidor 2> $curl_err)
remote_transaction=$(curl -s --connect-timeout 1,5 --show-error -w "~%{http_code}" -X POST -H "X-Signature: $(sign_file $registros/$file.sig)" -H "Content-Type: application/json" -d @$registros/$file $servidor 2> $curl_err)
remote_response="$(echo $remote_transaction | cut -d '~' -f 1)"
server_error="$(echo $remote_transaction | cut -d '~' -f 2)"
if [ ${#remote_response} -eq 36 ];then
if [ $local_transaction_uuid == $remote_response ]; then
mv $registros/$file $registros/$file.sign $historicos
mv $registros/$file $registros/$file.sig $historicos
echo -e "$remote_response: \e[92mOK\e[0m"
fi
else