How Do You SSH to a GCP server?

Problem scenario
You cannot SSH into a Linux Google Cloud Platform server.  How do you create new GCP servers that you can SSH into?

Solution
Summary
Use the “Startup script” in Google Cloud Platform.  This script comes with precautions.  Be careful when pasting it.  The lines can potentially not wrap properly.  Carriage returns could be introduced to make this script fail.  Be very careful because this script creates a user with sudoer privileges. 

How Do You Install Ansible on a Debian Linux Server Running in GCP?

Problem scenario
You are using Google Cloud Platform, and you have a Debian server.  You do not want to configure any PPAs for your system.*  How do you install and configure Ansible on a Debian Linux system?

Solution
Prerequisite

We strongly recommend having 2.5 GB of memory (either in RAM or with a combination of RAM and swap space).  

How Do You Use GCP’s App Engine?

Problem scenario
You want to leverage GCP’s serverless App Engine component with its scalability.  What do you do?

Solution
1.  Go to the cloud shell.  In the web UI of GCP in the upper righthand corner go to the icon that looks like this: “>_” and click on it.  From cloud shell run these commands:

git clone https://github.com/GoogleCloudPlatform/python-docs-samples

cd python-docs-samples/appengine/standard_python37/hello_world

virtualenv –python python3 ~/envs/hello_world

source ~/envs/hello_world/bin/activate

pip install -r requirements.txt

python main.py

2. 

How Do You Troubleshoot the Bash Script Error “line 5: $’\r’: command not found”?

Problem scenario
You drafted a Bash script on a Windows computer.  You then uploaded it to Google Cloud Platform via a web browser feature.  When you run the bash script on a Linux server (e.g., in GCP), you get this error “line 5: $’\r’: command not found”.  You do not want to install dos2unix or any new packages.  What should you do?

Solution
The file needs to be modified or “cleaned up.” 

How Do You Get a GCP Server to Present a Website on the Internet?

Problem scenario
You want to browse the web UI of a web application that you set up on a Linux machine in GCP.  How do you get a web service (e.g., Nginx, Apache web server, SonarQube or Jenkins) to work when the server is in Google Cloud Platform?

Solution
Prerequisites
This assumes you have deployed the web application.  If you want to deploy Nginx,

How Do You Install Docker on Debian 9 in GCP?

Problem scenario
You are running Debian 9 in GCP.  You want to install Docker on this server.  What should you do?

Solution
1.  Create a script in /tmp/ call installer.sh with the following lines of content:

#!/bin/bash
apt-get -y update
apt-get install -y apt-transport-https ca-certificates wget software-properties-common
wget https://download.docker.com/linux/debian/gpg
apt-key add gpg
echo “deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable” | sudo tee -a /etc/apt/sources.list.d/docker.list
apt-get -y update
apt-cache policy docker-ce
apt-get -y install docker-ce

2. 

How Do You Prepare Any Distribution of Linux in GCP to Have Similar Features to New AWS Instances?

Problem scenario
You want to have your Google Cloud Platform servers be ready for what you consider to be “regular” usage.  What should you do to get a server to be ready for these four things listed below?

1.  Able to SSH into it via Putty with a non-root user.
2.  Able to sudo with this non-root user.
3.  Files when modified in vi in “insert mode” can to receive clipboard-copied content with a right-click of a mouse.

How Do You Install Puppet Master on a Debian Linux Server in GCP?

Problem scenario
In Google Cloud Platform you have a Debian Linux server.  You want to install Puppet master on it.  What should you do?

Solution

Prerequisites
We suggest having at least 4.5 GB of memory.  This can be from RAM or a combination of RAM and swap space.  To create 4 GB of /swap/space you can see this posting as a guide,