Creating SSH keys

Generate a new key

If you don’t have an existing SSH key that you wish to use, generate one as follows:

  1. Open a terminal on your local computer and enter the following:

    ssh-keygen -t ed25519 -C "your_email@example.com"

    Associating the key with your email address helps you to identify the key later on.

    You’ll see a response similar to this:

    chaiss@C02FP1JWMD6V ~ % ssh-keygen -t ed25519 -C chaiss@email.com
    Generating public/private ed25519 key pair.
    Enter file in which to save the key (/Users/chaiss/.ssh/id_ed25519): 
  2. Just press <Enter> to accept the default location and file name. If the .ssh directory doesn’t exist, the system creates one for you.
  3. Enter, and re-enter, a passphrase when prompted.
    The whole interaction will look similar to this:

    chaiss@C02FP1JWMD6V ~ % ssh-keygen -t ed25519 -C chaiss@email.com
    Enter file in which to save the key (/Users/chaiss/.ssh/id_ed25519): 
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 

ShareX custom command line for two audio sources

ffmpeg.exe -rtbufsize 400M -f dshow -framerate 30 -i video="screen-capture-recorder" -f dshow -i audio="virtual-audio-capturer" -f dshow -i audio="Micrófono (Realtek High Definit" -filter_complex amix=inputs=2:duration=first:dropout_transition=3 -c:v libx264 -r 30 -preset fast -tune zerolatency -crf 28 -pix_fmt yuv420p -movflags +faststart -c:a aac -ac 2 -b:a 128k -y "output.mp4"

Start Chrome in remote debugging

chrome.exe --remote-debugging-port=9222 --ignore-certificate-errors --ignore-urlfetcher-cert-requests --user-data-dir=D:\chrome --app=http://localhost:4200/
It’s important to define the path for user-data-dir
Other alternatives not tested are:
chrome.exe --remote-debugging-port=9222 --app=http://localhost:4200/
chrome.exe --remote-debugging-port=9222 -incognito --new-window http://localhost:4200/
chrome.exe --remote-debugging-port=9222 -incognito --app=http://localhost:4200/
chrome.exe --remote-debugging-port=9222 --new-window http://localhost:4200/

Setup NAT, DHCP and DNS server on Alpine VirtualBox

I installed the following software versions:
VirtualBox 6.1
Alpine 3.14

I have deployed Alpine as a virtual machine in VirtualBox, that step takes a little more time but is fast. So it’s necessary to define the network configuration of Alpine, take into account the NAT and DHCP  server needs to have an assigned static IP so, on that regard I edited this file /etc/network/interfaces like this:


auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 192.168.201.2
netmask 255.255.255.0

eth0 represents the public network. The NAT network is assigned by VirtualBox host.
eth1 represents the private network. I created a new Host Network address/mask in VirtualBox’s Host Network Manager with disabled DHCP server. The address/mask was 192.168.201.1/24

The host name or the server name for this virtual machine was assigned editing the following files:

vi /etc/hostname:


alpine-nat

vi /etc/hosts


127.0.0.1          localhost.localdomain  localhost
::1                    localhost.localdomain  localhost
192.168.201.2  alpine-nat.mplb.localnet alpine-nat

After that reboot your virtual machine.

Activates additional repositories for Alpine’s apk command.

Edit this file:
vi /etc/apk/repositories


alpine-nat-repos


After that executes the commands:
apk update

Installs IPTABLES with NAT configuration

Follows the following commands in bash:


apk add iptables
rc-update add iptables

echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p

#eth0 is the PUBLIC_NET
#eth1 is the PRIVATE_NET

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

/etc/init.d/iptables save
/etc/init.d/iptables restart

Installs DNS/DHCP server in Alpine

I am going to install dnsmasq server, that provides dns and dhcp functionalities, so executes this command:
apk add –no-cache –virtual=run-deps dnsmasq

Edit or create the following files:

vi /etc/dnsmasq.d/01-base.conf


domain-needed
bogus-priv
no-resolv
expand-hosts

vi /etc/dnsmasq.d/02-nameservers.conf


server=8.8.8.8
server=8.8.4.4

vi /etc/dnsmasq.d/03-localresolv.conf


local=/mplb.localnet/
#eth1 PRIVATE_NET
interface=eth1
listen-address=::1,127.0.0.1
domain=mplb.localnet

vi /etc/dnsmasq.d/04-dhcp.conf


dhcp-range=192.168.201.100,192.168.201.200,24h
dhcp-authoritative
dhcp-leasefile=/var/lib/dnsmasq/dnsmasq.leases
dhcp-host=alpine-master
dhcp-host=alpine-node01
dhcp-host=alpine-node02

The hosts alpine-master, alpine-node01 and alpine-node02 are servers or workstations of the network and need to have the domain name set up as mplb.localnet besides theses hosts are going to have an static IP assigned by the DHCP server.

Then, it executes this sequence of commands:

chmod 0775 /etc/dnsmasq.d
chmod 0664 /etc/dnsmasq.d/*
sudo dnsmasq --test
mkdir /var/lib/dnsmasq/
/etc/init.d/dnsmasq stop

If you want to execute the dnsmasq server in test mode you can edit this command:

sudo dnsmasq --no-daemon --log-queries

Otherwise:

/etc/init.d/dnsmasq start

Setting up shared folder in Virtualbox for Alpine 3.14

Executes this sequence of commands:

sudo apk add virtualbox-guest-additions
sudo rc-update add virtualbox-guest-additions default
sudo echo vboxpci >> /etc/modules
sudo echo vboxdrv >> /etc/modules
sudo echo vboxnetflt >> /etc/modules
sudo apk update
sudo apk upgrade --update-cache --available
sudo reboot

Before to mount, it's needed to configure a shared folder in Virtualbox like this:
virtualbox_shared
Then:

sudo modprobe -a vboxsf
sudo mkdir /mnt/vbox_shared
sudo mount -t vboxsf vbox_shared /mnt/vbox_shared

Procedure to generate private keys in rsa

Como generar llaves RSA privada y pública

  • Tener instalado el openssl 

  • Version del openssl: OpenSSL 1.1.1c 28 May 2019  

Comando para generar la llave RSA privada de 2048 bits:

openssl genrsa -F4 -out mplb.dev.pkcs1.pem 2048

El archivo generado se encontrará en la carpeta actual del comando ejecutado cuyo nombre es: mplb .dev.pkcs1.pem

Comando para generar el archivo de llave pública, este archivo es el que se distribuye a las entidades externas:

openssl rsa -in mplb.dev.pkcs1.pem -outform PEM -pubout -out mplb.dev.x509.pem

El comando anterior necesita como entrada el archivo de la llave privada para generar el archivo de llave pública.

El nombre del archivo de llave publica se genera en el mismo folder del comando y el nombre es: mplb .dev.x509.pem

 

 

Some maven properties

#maven ssl tls
#enable use of relaxed SSL check for user generated certificates.
-Dmaven.wagon.http.ssl.insecure=true

#enable match of the server's X.509 certificate with hostname. If disabled, a browser like check will be used.
-Dmaven.wagon.http.ssl.allowall=true

#ignore issues with certificate dates.
-Dmaven.wagon.http.ssl.ignore.validity.dates=true

Java code template for connection to tomcat server authenticated by ssl certificate

import java.net.URI;
import java.nio.charset.Charset;

import org.springframework.http.HttpMethod;
/*import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.methods.GetMethod;*/
import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.StreamUtils;

public class ClientConnectionTest {
static {
System.setProperty("javax.net.ssl.trustStore", "C:/Users/s6026865/projects/temp/imagine-api-1.0.0-sources-0.3/client-truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "client-truststore");
System.setProperty("javax.net.ssl.keyStore", "C:/Users/s6026865/projects/temp/imagine-api-1.0.0-sources-0.3/client-keystore.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "client-keystore");
}

/**
* @param args
* @throws IOException
* @throws HttpException
*/
public static void main(String[] args) throws Exception {
ClientHttpRequestFactory requestFactory = new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory());
ClientHttpRequest request = requestFactory.createRequest(URI.create("https://TCDIGITAL35ZZZ:8443"), HttpMethod.GET);
ClientHttpResponse response = request.execute();
String body = StreamUtils.copyToString(response.getBody(), Charset.forName("UTF-8"));
System.out.println(body);

}
}