/
2.7.3. SSH connection and script execution

2.7.3. SSH connection and script execution

Here are the steps to perform to establish the connection to the machine using SSH/WinSCP. The goal is to bring the edited script to the machine with the customer data.

To perform the configuration, you will have to edit our script to have the client data before generating the user in the database - the appropriate editions for the script and how to run it is described in the following sections.

You can edit the script on our own system, send it to the remote system via WinSCP and run it from our SSH login.

Since the script has few lines, we could also not use WinSCP, and simply paste the contents of the script into a terminal text editor (nano, vi, ...) in our SSH login and then run it.


In order to make the connections, it will also be necessary that you are connected to the VPN of b+dgtal, our user should have been previously authorized.

 
The process is described below:

1-      Before carrying out the connection to the machine it will be necessary to have:

  • The IP address (or host address) of the machine.
  • An open port 22 on the machine for the connection (or another ssh-enabled port).
  • Authentication credentials to connect to the machine (usually given in a Keepass, .kdb or .kdbx file).

2-      Connection via PuTTY.

Once you have started SSH, you should have access to the machine's file system. Moves to the download directory:
Cd ~/Downloads/

If you do not want to use WinSCP, once you have made the necessary edits to the script, you can open a text editor and create the corresponding file.
Vi Table GenerationPostgreSQLv1.sql
Or
Vi Table GenerationPostgreSQLPASARELAv1.sql

Press i, and paste the contents once copied with right click. Save and leave with: wq


3-      Connection via WinSCP

Once logged in, and once you have completed the necessary script edits described in the following sections, you can drag the script file from the local file system to the remote file system using the WinSCP graphical interface.

4-  Once we have changed the data of the script, we execute it, there are two methods to execute it: From terminal command or from graphic interface with pgadmin.

a-     You can execute the script directly from a terminal, indicating as an argument the location of the script

Fuse Case

 psql -U fuseadmin -d siiprod_db -a -f ~/Downloads/fuse_conf/scripts-sql/GeneraciondetablasPostgreSQLv1.sql

Pasarela Cse

 psql -U fuseadmin -d siiprod_db -a -f ~/Downloads/fuse_conf/scripts-sql/GeneraciondetablasPostgreSQLPASARELAv1.sq

b-      Execution using pgadmin (if graphic option is available from SSH)

  • If the database user is the same between systems it is not necessary to change it, otherwise, it will be necessary to change the OWNER in all the tables.
  • Open pgadmin3.
  • Click on the sql icon.
  • Paste the contents of the script and execute it.

5-     Verify proper script execution
Queries can be made to the database using the psql command and see the contents of the different tables. For example, to query AGRUPACION_EXT

psql -U fuseadmin -d siiprod_db –x -c 'SELECT * FROM "AGRUPACION_EXT";'

6-      Change the tenant and security key
Edit ~/sii/tomcat/conf/wsaeat/wsaeat-conf.properties

Change the values of "wsaeat.clave", with a key (UUID) generated to secure the encryption of certificate data (the key must be unique for each environment).

Avvale 2024