Introdução - Quero configurar um servidor Git na camada gratuita do GCP
Olá, sou o incompetente.
De alguma forma, fiz login no próprio GCP depois de muito tempo?
Parece que o último projeto que criei foi em 2016...

Parece que é atualizado quando você acessa, então My First Project deve ser ainda mais antigo...
Quer dizer, agora é 2024, então faz 8 anos... Eu tinha 15 anos!!!!
O tempo é cruel.
Sinto que cresci, mas também que regredi em alguns aspectos... Não, a regressão também inclui o significado de evolução. Vamos ser positivos.
A propósito, depois de comer uma refeição deliciosa na sexta-feira, sinto vontade de relaxar.



Introdução
Eu também tenho uma conta OCI, mas falhei na escolha da região no registro inicial e a deixei de lado por mais de meio ano? Mesmo quando verifico ocasionalmente, os recursos da camada gratuita nunca estão disponíveis.
Quer dizer, por alguma razão, sou o único ao meu redor que não consegue usá-lo... Provavelmente pensei 'regiões menores devem ter mais recursos sobrando!' e me registrei, o que resultou em um fracasso total.
Como também usarei o ecossistema Google no trabalho, aproveitarei esta oportunidade para configurar um servidor Git no GCE.
Além disso, há outra razão: acho que ter um servidor Git fora de casa facilitaria o backup de dados. Quanto à rede, se eu for o único a usá-lo, provavelmente não serei cobrado, e a razão pela qual não usei o GCP até agora é esta ↓
A camada gratuita do Google Cloud Platform (GCP) inclui 1GB de tráfego de rede de saída.
Isso é bastante problemático. Na verdade, é muito problemático. No entanto, se for apenas para um servidor Git de uso pessoal, não parece ser algo com que se preocupar muito, então eu estava pensando vagamente nisso e planejando fazer quando tivesse tempo livre.
Quero usar totalmente de graça
Esses sistemas de cobrança ficam mais difíceis de entender a cada ano, então você deve seguir as pessoas que atualizam o conhecimento sobre como usá-los totalmente de graça. Suas explicações detalhadas são realmente apreciadas.
Dito isso, não sinto que a interface do usuário mudou muito em relação ao passado, mas é mais provável que minha memória esteja apenas fraca.
Criar uma instância de VM na camada gratuita do GCP
Construindo um servidor usando a camada gratuita do Google Cloud Platform (GCP)
Criação rápida de usuário
Como o nome de usuário padrão da conta Google é um pouco estranho, vou mudar para root, criar um usuário e configurá-lo para permitir SSH.
root@git-srv1:~# adduser haturatu
Adding user `haturatu' ...
Adding new group `haturatu' (1002) ...
Adding new user `haturatu' (1002) with group `haturatu (1002)' ...
Creating home directory `/home/haturatu' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for haturatu
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
Adding new user `haturatu' to supplemental / extra groups `users' ...
Adding user `haturatu' to group `users' ...
root@git-srv1:~# usermod -aG sudo haturatu
root@git-srv1:~# su - haturatu
haturatu@git-srv1:~$
Configurações SSH
haturatu@git-srv1:~$ vim .ssh/authorized_keys
haturatu@git-srv1:~$ chmod 600 .s
.ssh/ .sudo_as_admin_successful
haturatu@git-srv1:~$ chmod 600 .ssh/authorized_keys
haturatu@git-srv1:~$ chmod 700 .ssh
haturatu@git-srv1:~$
haturatu@git-srv1:~$ sudo service sshd restart
Configurações de Firewall
haturatu@git-srv1:~$ sudo apt install ufw
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
ufw
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 168 kB of archives.
After this operation, 878 kB of additional disk space will be used.
Get:1 file:/etc/apt/mirrors/debian.list Mirrorlist [30 B]
Get:2 https://deb.debian.org/debian bookworm/main amd64 ufw all 0.36.2-1 [168 kB]
Fetched 168 kB in 0s (1133 kB/s)
Preconfiguring packages ...
Selecting previously unselected package ufw.
(Reading database ... 68496 files and directories currently installed.)
Preparing to unpack .../archives/ufw_0.36.2-1_all.deb ...
Unpacking ufw (0.36.2-1) ...
Setting up ufw (0.36.2-1) ...
Creating config file /etc/ufw/before.rules with new version
Creating config file /etc/ufw/before6.rules with new version
Creating config file /etc/ufw/after.rules with new version
Creating config file /etc/ufw/after6.rules with new version
Created symlink /etc/systemd/system/multi-user.target.wants/ufw.service → /lib/systemd/system/ufw.service.
Processing triggers for rsyslog (8.2302.0-1) ...
Processing triggers for man-db (2.11.2-2) ...
haturatu@git-srv1:~$ sudo ufw allow 22/tcp
Rules updated
Rules updated (v6)
haturatu@git-srv1:~$ sudo ufw reload
Firewall not enabled (skipping reload)
haturatu@git-srv1:~$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup
haturatu@git-srv1:~$ sudo ufw reload
Firewall reloaded
Hora do SSH
Como já havia inserido a chave com vim .ssh/authorized_keys, agora é só fazer SSH do PC cliente (o laptop que estou usando).
alleycat:[haturatu]:~$ ssh -l haturatu gce-global-ip
The authenticity of host 'nyao-n' can't be established.
ED25519 key fingerprint is SHA256:nyannyan
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'nyannyan' (ED25519) to the list of known hosts.
Linux git-srv1 6.1.0-27-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.115-1 (2024-11-01) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
haturatu@git-srv1:~$ uname -a
Linux git-srv1 6.1.0-27-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.115-1 (2024-11-01) x86_64 GNU/Linux
Terminei rapidamente!
Bem, ficou longo porque colei um monte de coisas, então continua na parte dois.