Setup git on gcp
Set up personal SSH keys on Linux
Use Git cmd to manage repo
Install docker so we can use docker compose
Create SSL certificate
GCP IP Address
Interact with postgres docker container
Setup git on gcp
To install Git on Linux, follow these steps:
Update the package index:
sudo apt update
Install Git:
sudo apt install git
Verify the installation:
git --version
You should see the installed Git version.
Set up personal SSH keys on Linux
To clone a repo on bitbucket, you need to set up personal SSH keys
- Install OpenSSH on your device. For Debian, Ubuntu, Linux Mint, and other Debian-based distributions:
sudo apt update && sudo apt install openssh-client
ssh -V
- Start the SSH Agent. To check if SSH agent is running:
ps -ax | grep ssh-agent
output should be like this
19998 ?? 0:00.20 /usr/bin/ssh-agent -l
To start the agent, run:
eval $(ssh-agent)
You may need to add this command to your ~/.bashrc
, ~/.zshrc
, ~/.profile
, or equivalent shell configuration file.
use
nano ~/.profile
then put eval $(ssh-agent)
on it
cd ~
ssh-keygen -t ed25519 -b 4096 -C "{username@emaildomain.com}" -f ~/.ssh/{ssh-key-name}
{username@emaildomain.com} is the email address associated with the Bitbucket Cloud account, such as your work email account.
{ssh-key-name} is the output filename for the keys. We recommend using a identifiable name such as bitbucket_work.
Once complete, ssh-keygen will output two files:
{ssh-key-name}
— the private key.
{ssh-key-name}.pub
— the public key.
ssh-add ~/.ssh/{ssh-key-name}
To ensure the correct SSH key is used when connecting to Bitbucket, update or create your SSH configuration file (~/.ssh/config
) with the following settings:
Host bitbucket.org
AddKeysToAgent yes
IdentityFile ~/.ssh/{ssh-key-name}
- Provide Bitbucket Cloud with your public key.
- Check that your SSH authentication works. To test that the SSH key was added successfully:
ssh -T git@bitbucket.org
output should be like this
authenticated via ssh key.
You can use git to connect to Bitbucket. Shell access is disabled
Use Git cmd to manage repo
- clone the repo using clone command
git clone git@bitbucket.org:{org-name}/{repo-name}.git
above is just sample, you can get the command from clone button in bitbucket repository
- move to repository folder using cd command
cd {repo-name}
- use git status to check changes and your current branch
git status
- change current branch using git checkout
git checkout {branch-name}
- update your local branch and local commit history according to remote
git fetch
- pull the changes from remote using git pull
git pull
Install docker so we can use docker compose
full step to install docker on debian are in here
summarize steps:
- Run the following command to uninstall all conflicting packages:
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
- Set up Docker's
apt
repository. the step are divided by 2:
First, Add Docker's official GPG key, run these commands:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Second, Add the repository to Apt sources, run these commands:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Install the Docker packages.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Verify that the Docker Engine installation is successful by running the hello-world image.
docker --version
Create SSL certificate
Step-by-step instructions to install Certbot on linux
Install snapd
sudo apt update
sudo apt install snapd
Update snapd
sudo snap install core
Remove previous Certbot packages
sudo apt-get remove certbot
Install Certbot
sudo snap install --classic certbot
Once certbot is installed, execute the following command to ensure the certbot
command can be run:
sudo ln -s /snap/bin/certbot /usr/bin/certbot
Generate SSL Certificate with Let’s Encrypt
sudo certbot certonly --manual --preferred-challenges dns -d *.domain.com -d domain.com
you will get acme value to put on your DNS, in above example, you will get 2 acme that need to put orderly one by one, below are sample DNS TXT acme
Please deploy a DNS TXT record under the name:
_acme-challenge.domain.com.
with the following value:
pdUqtrqSHGKKPv3x2yDyvi0hZhMEUmJtxay82Fhd29f
you need to put value above to your DNS dashboard, my DNS dashboard are look like this
after you add the record(s), you can enter on the cmd to continue to the next acme or the next step
Success generated SSL will have this info
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/domain.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/domain.com/privkey.pem
This certificate expires on 2024-12-17.
These files will be updated when the certificate renews.
use both according your approach how to apply SSL on your domain
GCP IP Address
Upgrade your internal and external IP address on GCP to static, so it will not changing when the instance got restart
register your external address to your dns
Interact with postgres docker
connect to docker cli
sudo docker exec -it {docker-container-name} sh
connect to postgres cli
psql -h localhost -U {user-name}
create database
CREATE DATABASE {database-name};
connect to the database
\c {database-name}
or you can immediate put the database name as parameter while connect to postgres cli
psql -h localhost -U {user-name} -d {database-name}
Top comments (0)