Alberto Garcia

🔗 – Unitat de xarxa compartida

Unitat de xarxa compartida Configuració del servidor NFS Click Recurs compartit per tots els servidors amb permisos d’escriptura Click Recurs compartit públic de només lectura Click Configuració permanent del recurs compartit en els clients Click

Recurs compartit per tots els servidors amb permisos d’escriptura

Recurs compartit per tots els servidors amb permisos d’escriptura El primer que farem serà crear dues carpetes una serà únicament lectura i un altre que serà lectura i escriure. sudo mkdir -p /srv/nfs/compartit-rw sudo mkdir -p /srv/nfs/compartit-ro A la carpeta d’escriptura li donarem permisos totals sudo chown nobody:nogroup /srv/nfs/compartit-rw sudo chmod 777 /srv/nfs/compartit-rw A la carpeta de lectura la deixarem més protegida. sudo chmod 755 /srv/nfs/compartit-ro Ara configurarem l’arxiu de NFS  sudo vim /etc/exports vagrant@debian:~$ sudo cat /etc/exports # /etc/exports: the access control list for filesystems which may be exported # Afegirem les seguents lineas /srv/nfs/compartit-rw 192.168.100.0/24(rw,sync,no_subtree_check,no_root_squash) /srv/nfs/compartit-ro 192.168.100.0/24(ro,sync,no_subtree_check) Ara faran una petita comprovació que esta bé, serà reiniciar el servei, 1 perquè és actualíssim amb la nova configuració i 2 per veure si arranca ve i no de cap error. sudo systemctl restart nfs-kernel-server sudo systemctl status nfs-kernel-server vagrant@debian:~$ sudo systemctl restart nfs-kernel-server sudo systemctl status nfs-kernel-server ● nfs-server.service – NFS server and services Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; preset: enabled) Active: active (exited) since Thu 2026-02-26 11:40:53 CET; 27ms ago Process: 3552 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS) Process: 3553 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS) Main PID: 3553 (code=exited, status=0/SUCCESS) CPU: 2ms Feb 26 11:40:53 debian systemd[1]: Starting nfs-server.service – NFS server and services… Feb 26 11:40:53 debian systemd[1]: Finished nfs-server.service – NFS server and services.

Configuració del servidor NFS

Configuració del servidor NFS El protocol NFS permet que diferents equips en una xarxa accedeixin a arxius remots com si estiguessin en el seu propi disc local. Centralització de dades: En lloc de tenir còpies d’un arxiu en cada PC, els guardes en un únic servidor. Això facilita enormement les còpies de seguretat (còpia de seguretat) i la integritat de la informació. Eficiència en xarxa: NFS està optimitzat per a transferències d’arxius dins de xarxes locals, reduint la sobrecàrrega de protocols més pesats, Implementació i configuració El primer que hem de fer es fer l’instalacio del paquet de nfs, per fer-ho utilitzarem la seguent comanda  sudo apt-get install nfs-kernel-server nfs-common Vagrant@debian:~$ apt list –installed | grep nfs-kernel-server WARNING: apt does not have a stable CLI interface. Use with caution in scripts. nfs-kernel-server/oldstable,now 1:2.6.2-4+deb12u1 amd64 [installed] Ara el que farem serà crear una carpeta de prova, que és la que veuran els usuaris. sudo mkdir -p /srv/nfs/compartit sudo chown nobody:nogroup /srv/nfs/compartit # Permisos para evitar conflictos de usuarios Per continuar haurem de configurar l’arxiu de configuració, i afegirem la següent línia, aquesta configur sudo vim /etc/exports vagrant@debian:~$ sudo cat /etc/exports # /etc/exports: the access control list for filesystems which may be exported #Afegirer la seguent linea /srv/nfs/compartit 192.168.100.0/24(rw,sync,no_subtree_check) Ara faran una petita comprovació que esta bé, serà reiniciar el servei, 1 perquè és actualíssim amb la nova configuració i 2 per veure si arranca ve i no de cap error. sudo systemctl restart nfs-kernel-server sudo systemctl status nfs-kernel-server vagrant@debian:~$ sudo systemctl restart nfs-kernel-server sudo systemctl status nfs-kernel-server ● nfs-server.service – NFS server and services Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; preset: enabled) Active: active (exited) since Thu 2026-02-26 09:39:34 CET; 30ms ago Process: 2999 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS) Process: 3000 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS) Main PID: 3000 (code=exited, status=0/SUCCESS) CPU: 2ms Feb 26 09:39:34 debian systemd[1]: Starting nfs-server.service – NFS server and services… Feb 26 09:39:34 debian systemd[1]: Finished nfs-server.service – NFS server and services.

Compartició de claus SSH amb les MVs

Compartició de claus SSH amb les MVs El que farem serà des de cada màquina de cada membre del grup, farem la compartició de claus amb els tres 3 rúters/màquines virtuals dels altres membres.  Alberto El primer que farem serà compartir les claus en el router del Izan, [11:27:37][Documents][agarcia@agarcia]-$ ssh-copy-id vagrant@172.25.215.12 /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys vagrant@172.25.215.12's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'vagrant@172.25.215.12'" and check to make sure that only the key(s) you wanted were added. Despres el que farem serà compartir les claus en el router del Jan, [11:31:41][Documents][agarcia@agarcia]-$ ssh-copy-id vagrant@172.25.212.12 /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys vagrant@172.25.212.12's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'vagrant@172.25.212.12'" and check to make sure that only the key(s) you wanted were added. Tambe compartirem les claus en el router del Adrian, [11:32:59][Documents][agarcia@agarcia]-$ ssh-copy-id vagrant@172.25.205.12 The authenticity of host '172.25.205.12 (172.25.205.12)' can't be established. ED25519 key fingerprint is SHA256:Ixs7PihAe47N2MIQfNgSSZDP4yMseOfJs7UFAoP2PrI. This host key is known by the following other names/addresses: ~/.ssh/known_hosts:18: [hashed name] ~/.ssh/known_hosts:27: [hashed name] ~/.ssh/known_hosts:35: [hashed name] ~/.ssh/known_hosts:40: [hashed name] Are you sure you want to continue connecting (yes/no/[fingerprint])? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys vagrant@172.25.205.12's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'vagrant@172.25.205.12'" and check to make sure that only the key(s) you wanted were added. Izan El primer que farem serà compartir les claus en el router del Alberto, [11:36:03][~][ilecina@ilecina]-$ ssh-copy-id vagrant@172.25.208.12 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ilecina/.ssh/id_ed25519.pub" The authenticity of host '172.25.208.12 (172.25.208.12)' can't be established. ED25519 key fingerprint is SHA256:Ixs7PihAe47N2MIQfNgSSZDP4yMseOfJs7UFAoP2PrI. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys vagrant@172.25.208.12's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'vagrant@172.25.208.12'" and check to make sure that only the key(s) you wanted were added. Despres el que farem serà compartir les claus en el router del Jan, [11:40:03][~][ilecina@ilecina]-$ ssh-copy-id vagrant@172.25.212.12 /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys vagrant@172.25.212.12's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'vagrant@172.25.212.12'" and check to make sure that only the key(s) you wanted were added. Tambe el que serà compartir les claus en el router del Adrian, [11:37:14][~][ilecina@ilecina]-$ ssh-copy-id vagrant@172.25.205.12 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ilecina/.ssh/id_ed25519.pub" The authenticity of host '172.25.205.12 (172.25.205.12)' can't be established. ED25519 key fingerprint is SHA256:Ixs7PihAe47N2MIQfNgSSZDP4yMseOfJs7UFAoP2PrI. This host key is known by the following other names/addresses: ~/.ssh/known_hosts:47: [hashed name] Are you sure you want to continue connecting (yes/no/[fingerprint])? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys vagrant@172.25.205.12's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'vagrant@172.25.205.12'" and check to make sure that only the key(s) you wanted were added. Jan El primer que farem serà compartir les claus en el router del Alberto, [12:05:03][~][jcanet@jcanet]-$ ssh-copy-id vagrant@172.25.208.12 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/jcanet/.ssh/id_ed25519.pub" The authenticity of host '172.25.208.12 (172.25.208.12)' can't be established. ED25519 key fingerprint is SHA256:Ixs7PihAe47N2MIQfNgSSZDP4yMseOfJs7UFAoP2PrI. This host key is known by the following other names/addresses: ~/.ssh/known_hosts:16: [hashed name] ~/.ssh/known_hosts:20: [hashed name] ~/.ssh/known_hosts:21: [hashed name] Are you sure you want to continue connecting (yes/no/[fingerprint])? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys vagrant@172.25.208.12's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'vagrant@172.25.208.12'" and check to make sure that only the key(s) you wanted were added. Tambe el que farem serà compartir les claus en el router del Izan, [12:05:25][~][jcanet@jcanet]-$ ssh-copy-id vagrant@172.25.215.12 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/jcanet/.ssh/id_ed25519.pub" The authenticity of host '172.25.215.12 (172.25.215.12)' can't be established. ED25519 key fingerprint is SHA256:KenCe1t9FWSoXFRCgMuik7eNo7ul0tJu+/KYghNQSRE. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys vagrant@172.25.215.12's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'vagrant@172.25.215.12'" and check to make sure that only the key(s) you wanted were added. I despres el que farem serà compartir les claus en el router del Adrian, [12:07:09][~][jcanet@jcanet]-$ ssh-copy-id vagrant@172.25.205.12 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/jcanet/.ssh/id_ed25519.pub" The authenticity of host '172.25.205.12 (172.25.205.12)' can't be established. ED25519 key fingerprint is SHA256:Ixs7PihAe47N2MIQfNgSSZDP4yMseOfJs7UFAoP2PrI. This host key is known by the following other names/addresses: ~/.ssh/known_hosts:13: [hashed name] ~/.ssh/known_hosts:17: [hashed name] ~/.ssh/known_hosts:18: [hashed name] ~/.ssh/known_hosts:20: [hashed name] Are you sure you want … Read more

Configuració d’un servei FTP pels treballadors

Configuració d’un servei FTP pels treballadors El primer que hem de fer serà actualitzar els repositoris actuals i instal·lar els paquets del servei FTP, o farem amb la següent comanda. sudo apt update sudo apt install vsftpd vagrant@debian:~$ dpkg -s vsftpd | grep Version Version: 3.0.3-13+b2 Ara una vegada amb els paquets instalats anirem a fer la configuracio de l’archiu de configuracio que esta a la seguent ruta /etc/vsftpd.conf sudo vim /etc/vsftpd.conf Arxiu configuracio Aquest fitxer e on li dius al programa com s’ha de comportar i quines coses poden fer els usuaris quan es connectin. listen=YES Li diem al servidor que estigui escoltant a les connexions que arriben per la xarxa anonymous_enable=NO: Això es per seguretat. Diem que no volem intrusos; només gent que tingui un usuari i una contrasenya al sistema hi podrà entrar. I tant chroot_local_user=YES com allow_writeable_chroot=YES són per temes de seguretat, ja que bloquegés als usuaris que naveguin per on ells volen. write_enable=YES: Molt important. Si no poses això, només podries “mirar” els fitxers, però no podries penjar res nou ni esborrar res. local_umask=022: Això serveix per donar uns permisos estàndard als fitxers que puges, perquè després els puguis llegir sense complicacions # Example config file /etc/vsftpd.conf listen=YES # # Allow anonymous FTP? (Disabled by default). anonymous_enable=NO # # # Uncomment this to enable any form of FTP write command. write_enable=YES # local_umask=022 # dirmessage_enable=YES # use_localtime=YES # xferlog_enable=YES # connect_from_port_20=YES # chroot_local_user=YES allow_writeable_chroot=YES # secure_chroot_dir=/var/run/vsftpd/empty # pam_service_name=vsftpd # rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key ssl_enable=NO Proves Ara farem unes proves, per fer aquesta prova crearem un usuari, amb les seves carpetes de treball imaginaries els permisos d’aquestes carpetes. sudo adduser usuarioftp sudo mkdir -p /home/usuarioftp/ftp/subidas sudo chown nobody:nogroup /home/usuarioftp/ftp sudo chmod a-w /home/usuarioftp/ftp sudo chown usuarioftp:usuarioftp /home/usuarioftp/ftp/subidas Per contínua intentarem fer una prova contactar amb nosaltres a l’FTP des de l’usuari que acabem de crear (el primer error és perquè no està configurat per escoltar ipv6) ftp localhost vagrant@debian:~$ ftp localhost Trying [::1]:21 … ftp: Can't connect to `::1:21': Connection refused Trying 127.0.0.1:21 … Connected to localhost. 220 (vsFTPd 3.0.3) Name (localhost:vagrant): usuarioftp 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> Aquest fitxer e on li dius al programa com s’ha de comportar i quines coses poden fer els usuaris quan es connectin. listen=YES Li diem al servidor que estigui escoltant a les connexions que arriben per la xarxa anonymous_enable=NO: Això es per seguretat. Diem que no volem intrusos; només gent que tingui un usuari i una contrasenya al sistema hi podrà entrar. I tant chroot_local_user=YES com allow_writeable_chroot=YES són per temes de seguretat, ja que bloquegés als usuaris que naveguin per on ells volen. write_enable=YES: Molt important. Si no poses això, només podries “mirar” els fitxers, però no podries penjar res nou ni esborrar res. local_umask=022: Això serveix per donar uns permisos estàndard als fitxers que puges, perquè després els puguis llegir sense complicacions # Example config file /etc/vsftpd.conf listen=YES # # Allow anonymous FTP? (Disabled by default). anonymous_enable=NO # # # Uncomment this to enable any form of FTP write command. write_enable=YES # local_umask=022 # dirmessage_enable=YES # use_localtime=YES # xferlog_enable=YES # connect_from_port_20=YES # chroot_local_user=YES allow_writeable_chroot=YES # secure_chroot_dir=/var/run/vsftpd/empty # pam_service_name=vsftpd # rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key ssl_enable=NO Ara farem unes proves, per fer aquesta prova crearem un usuari, amb les seves carpetes de treball imaginaries els permisos d’aquestes carpetes. sudo adduser usuarioftp sudo mkdir -p /home/usuarioftp/ftp/subidas sudo chown nobody:nogroup /home/usuarioftp/ftp sudo chmod a-w /home/usuarioftp/ftp sudo chown usuarioftp:usuarioftp /home/usuarioftp/ftp/subidas Per contínua intentarem fer una prova contactar amb nosaltres a l’FTP des de l’usuari que acabem de crear (el primer error és perquè no està configurat per escoltar ipv6) ftp localhost vagrant@debian:~$ ftp localhost Trying [::1]:21 … ftp: Can't connect to `::1:21': Connection refused Trying 127.0.0.1:21 … Connected to localhost. 220 (vsFTPd 3.0.3) Name (localhost:vagrant): usuarioftp 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp>

Configuració de xarxa estàtica per servidors des del DHCP

Configuració de xarxa estàtica per servidors des del DHCP Per fer aquesta configuració el primer que haurem de fer serà anar a l’arxiu un es configura diferents coses, per accedir aquest arxiu usarem la següent comanda. cd /etc/dhcp/ Una vegada dintre de l’arxiu al final afegirem aquestes línies de codi canviant la informació per la qual necessitem  que el que faria falta canviar seria el mac que té la targeta de xarxa on volem posar la xarxa estàtica.  DNS + FTP SERVER host puerto-1 { hardware ethernet 08:00:27:D9:50:8A; fixed-address 192.168.100.3; } Arxiu final # dhcpd.conf # option definitions common to all supported networks… default-lease-time 600; max-lease-time 7200; authoritative; default-lease-time 600; max-lease-time 7200; # Alberto RED – 192.168.100.0 subnet 192.168.100.0 netmask 255.255.255.240 { range 192.168.100.2 192.168.100.14; option routers 192.168.100.1; } DNS + FTP SERVER host puerto-1 { hardware ethernet 08:00:27:D9:50:8A; fixed-address 192.168.100.3; }

🔐 – Pla de protecció

Pla de protecció Política de contrasenyes Click Política de protecció de dades Click Configuració del servei OpenLDAP Click Creació de contingut dins del directori Click Automatització de tasques amb ShellScripts Click Control de versions de codi Click

🏗️ – Infraestructura de serveis

Infraestructura de serveis Configuració de xarxa dinàmica per clients des del DHCP Click Configuració de xarxa estàtica per servidors des del DHCP Click Configuració d’un master DNS per la resolució del domini propi Click Configuració d’un servei FTP pels treballadors Click Configuració d’un slave DNS per la resolució del domini propi Click Col·locar el servei DHCP dins de la DMZ Click