How to handle SSH keys for multiple Github accounts and making it more convenient to login to servers.
- Download Gcloud SDK from this link and install it according to the instructions for your OS.
- Initialize the SDK following these instructions.
- Run
gcloud init
from a terminal and follow the instructions. - Make sure that your project is selected with the command
gcloud config list
- Run
- From your project's dashboard, go to Cloud Compute > VM instance
- Container: environment that runs an applications that is not dependent on the OS. Kind of like a lightweight VM. Containers are stateless; if you need to update the components inside, create another container instead.
- Image: template to create a container. Its components are defined by a
Dockerfile
. - Volume: storage area detached from the container for maintaining state. There are 4 types:
- Volumes: managed by Docker itself, they're stored in a separate part of the host filesystem (on Linux by default this would be
var/lib/docker/volumes
). Useful for production deployments. - Bind mounts: mount a specific directory or file from the host to the container, such as a project folder. Useful for development.
- Volumes: managed by Docker itself, they're stored in a separate part of the host filesystem (on Linux by default this would be
- Tmpfs mounts: mount a temporary file system in the container, which is stored in the host system's memory only, not on disk. Useful for sensitive information that should not be persisted between container restarts or for performance reaso
- SSH with local X (any X window should be run locally rather than remotely)
ssh -X user@instance
- Leave a process running even when you leave the SSH session
- Make your script executable with
chmod +x main.py
- 2 possible instructions:
- If console output does not matter (console output is still available in nohup.out but only if execution is finished successfully):
nohup python main.py &
- If output must be saved even if you interrupt the execution:
- (bash)
nohup python -u main.py > output.log &
- (bash)
- If console output does not matter (console output is still available in nohup.out but only if execution is finished successfully):
- Make your script executable with
- (zsh)
nohup python -u main.py > output.log &!
- Start your instance from Cgloud console
- (Local terminal) Change to your project
gcloud projects list
gcloud config set project my-project
- Create the ssh blob for easier connection
gcloud compute config-ssh
- Inside
~/ssh/
a newconfig
file should appear with the necessary info to connect. The host name should be enough to connect via SSHssh instance.zone.project
- In VSCode, with the Remote SSH extension, use the same instruction to add the necessary info in order to log into the instance. The passphrase will be asked.
I hereby claim:
- I am ziritrion on github.
- I am alvaronp (https://keybase.io/alvaronp) on keybase.
- I have a public key whose fingerprint is 994B DE62 2EC6 1B1D 6B09 CADF 4DA5 4041 B876 23F8
To claim this, I am signing this object: