Couldn’t load private key format too new

This issue happens when you use PuTTYgen to generate or convert to a ppk key.

When you use PuTTYgen to generate or convert to a ppk key and leave PuTTYgen settings as default, you might experience this issue.

From PuTTY version 0.75, the program uses a new format to generate the SSH private key; it uses ppk version 3. However, PuTTY 0.74 or earlier versions can’t read this format, and this can be a problem for programs that use PuTTY internally, like Solar PuTTY or MobaXtermn. If the internal PuTTY version is not compatible with PPK version 3, the program can’t use keys created with a default setting of PuTTY 0.75.

Solution

You can generate a new SSH key pair or change the private key format of an existing private key using PuTTYgen .

Step 1: Change the PuTTYgen PPK File Version to version 2.

Run the PuTTYgen program. Go to Key > Parameters for saving key files…

Changing the Version of the SSH Private Key

Change the PuTTygen PPK File Version to version 2.

Changing the Version of the SSH Private Key

Step 2: Generate a new SSH key pair or change the format of an existing one.

After following step one, you can now generate a key using the ppk version 2. You will be able to SSH to the cloud instance. This option is better if you are just creating the cloud instance. 

Step 3: Click on Load and search for your ppk key (version 3). Click Save private key, to convert the key to the old ppk format.

Changing the Version of the SSH Private Key

Move repository from Bitbucket to GitHub with all branches and commits

Step 1 : Create a Blank repository on Github without Readme.md

Step 2 : Moving all code and content from bitbucket

1. Check out the existing repository from Bitbucket:

$ git clone git@bitbucket.org:Cotocuschandan/testrepo.git

2. Now adding new GitHub Repository as upstream remote of the repository which is clone from bitbucket.

$ cd testrepo
$ git remote add upstream git@github.com:devops-school-com/ds-test.git

3. push all branches and tags to GitHub Repository using below commands

$ git push upstream master
$ git push --tags upstream

Step 3 : Add URL of New Github Repository as redirect URL

$ git remote set-url origin git@github.com:devops-school-com/ds-test.git

Step 4: At last Clone all branches and tags to GitHub Repository

$ git push --mirror

Edit old commit message

Filter Branch Command Line Method

Add this piece of code to Git Bash for project but update the commit ID and the commit message:

git filter-branch --msg-filter "test $(echo '$GIT_COMMIT') = $(git rev-parse 05163c9b8ba425369c9b1619d43ed17b16604ec3) && echo 'Adding theme files' || cat" -- --all

Force push the commit to Github.com with this:

git push origin master --force

Filter Branch Bash Method

Issue: Can’t read PATH

Add this to file named git-reword-commit inside C:\bin

#! /bin/bash
path_to_git='/c/Program Files/Git/mingw64/bin/'
PATH=$PATH:$path_to_git
echo $PATH
export PATH
REV=$1
MESSAGE=$2
FILTER="test $(echo '$GIT_COMMIT') = $(git rev-parse $REV) && echo $MESSAGE || cat"
git filter-branch --msg-filter "$FILTER" -- --all

Open cmd and go to directory C:\bin then type

bash git-reword-commit

PATH is supposed to make the git command work but get these errors:

': not a valid identifier: export: `PATH
git-reword-commit: line 7: git: command not found
git-reword-commit: line 8: git: command not found

Rebase Method

Issue: Only changes on one branch… if the change happened on Master you’ll only see on Master and not Develop. It also separates the two branches and they no longer intertwine.

Figure out how many commits to go back. If you get an error message you went back too far:

git rebase -i HEAD~133

If you didn’t go far back enough then undo it

git rebase --abort

When you see your commit, use the up and down keys to get to the line. Press “i” to enable editing of text. Change “pick” to “reword” and press “Esc” then type “:wq” which will save the file.

pick e499d89 Corrected syntax error 
pick 0c39034 Adding code prism.js
pick f7fde4a More css updates

# Rebase 9fdb3bd..f7fde4a onto 9fdb3bd
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

After I saved and closed, it then opened up the commit I renamed and I saved that with “:wq” as well.

Finish the rebase with:

git rebase --continue

Force push the commit to Github.com with this:

git push origin master --force

Set Up Docker Python

Requirements:
Install Python and Docker

Create folder on computer named docker-python and follow steps below:

cd /path/to/python-docker 
pip3 install Flask 
pip3 freeze | grep Flask >> requirements.txt 

Create app.py file and add this code

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, Docker!'

Create a Dockerfile for Python

# syntax=docker/dockerfile:1

FROM python:3.8-slim-buster

WORKDIR /app

COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt

COPY . .

CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]

Directory structure is now:

python-docker
|____ app.py
|____ requirements.txt
|____ Dockerfile

Build an image:

docker build --tag docker-python .

Run your image as a container with ability to open in browser

docker run --publish 5000:5000 docker-python

Test in terminal to see if works

curl localhost:5000
Hello, Docker!

Check Docker Desktop and you should see it listed as a running container with ability to open in browser!

WAMP Virtual Hosts

Setting Up Overall Structure

Keep localhost homepage in default location on C drive. Set up all websites to be virtual hosts that you configure from the localhost homepage which will be the name of website ending in .local.

Update httpd-vhosts.conf to make files.local URL point to the D drive. This will make WordPress sites work when the database is not updated with new domain. Add this code to the file:

<VirtualHost *:80>
   DocumentRoot "d:/sites"
   ServerName files.local
   <Directory "/">
      AllowOverride All
      Require local
      Allow from All
      Require local
   </Directory>
</VirtualHost>

Add an htaccess to C:\wamp64\www so that all localhost links except the homepage rewrite to files.local which points to D drive

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://files.local/$1 [L]

Setting Up HTTPS

  1. Download and Install OpenSSL
    OpenSSL is available in both 32 and 64 bit. Make sure you select the correct installer for your version of Windows. You can find the latest version of OpenSSL here https://slproweb.com/products/Win32OpenSSL.html. Navigate to your downloads folder and double click the installer. When Installing OpenSSL leave all settings default.
  2. Create Your Key and Certificate
    Open your start menu and Load Command Prompt as an Administrator and run the following commands.

    First, we will need to change our directory to where we installed OpenSSL.
    cd D:\Program Files\OpenSSL-Win64\bin

    Next, we will create our private key. You will be asked for a passphrase. Make it anything you want just make sure you remember it for the next step.
    openssl genrsa -aes256 -out private.key 2048
    openssl rsa -in private.key -out private.key

    Next, we will create our certificate. You will be asked several questions on this step. You can put whatever you like or just hit enter to leave it at default. The only one that really matters is Common Name (e.g. server FQDN) you will need to type “localhost” for this.
    openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500
  3. Move your Key and Certificate
    Create a folder named “key” in the C:\wamp64\bin\apache\apache2.4.23\conf directory.

    Navigate to c:/program files/openssl-win64/bin/ to find the certificate.crt and private.key that you just created. Both of these need to be moved to the new folder c:/wamp64/bin/apache/apache2.4.41/conf/key/.
  4. Edit Your httpd.conf File
    Open c:/wamp64/bin/apache/apache2.4.23/conf/httpd.conf and un-comment (remove the #) the following 3 lines:
    LoadModule ssl_module modules/mod_ssl.so
    Include conf/extra/httpd-ssl.conf
    LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
  5. Edit Your httpd-ssl.conf File
    Open up C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-ssl.conf and replace content with:
Listen 443

DocumentRoot "c:/wamp64/www"
ServerName localhost:443
ServerAdmin info@christinewilson.ca
SSLSessionCache "shmcb:${SRVROOT}/logs/ssl_scache(512000)"
ErrorLog "${SRVROOT}/logs/error.log"
TransferLog "${SRVROOT}/logs/access.log"
SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

<VirtualHost localhost:443>

	DocumentRoot "c:/wamp64/www"
	ServerName localhost:443
	ServerAlias localhost
	ServerAdmin info@christinewilson.ca
	ErrorLog "${SRVROOT}/logs/error.log"
	TransferLog "${SRVROOT}/logs/access.log"

	SSLEngine on
	SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
	SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

	<FilesMatch "\.(cgi|shtml|phtml|php)$">
		SSLOptions +StdEnvVars
	</FilesMatch>

	<Directory "d:/sites">
		SSLOptions +StdEnvVars
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		Require all granted
		AllowOverride All
	</Directory>

	BrowserMatch "MSIE [2-5]" \
			 nokeepalive ssl-unclean-shutdown \
			 downgrade-1.0 force-response-1.0

	CustomLog "${SRVROOT}/logs/ssl_request.log" \
			  "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

<VirtualHost files.local:443>
 
	DocumentRoot "d:/sites"
	ServerName files.local:443
	ServerAlias files.local
	ServerAdmin info@christinewilson.ca
	ErrorLog "${SRVROOT}/logs/error.log"
	TransferLog "${SRVROOT}/logs/access.log"

	SSLEngine on
	SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
	SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

	<FilesMatch "\.(cgi|shtml|phtml|php)$">
		SSLOptions +StdEnvVars
	</FilesMatch>

	<Directory "d:/sites">
		SSLOptions +StdEnvVars
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		Require all granted
		AllowOverride All
	</Directory>

	BrowserMatch "MSIE [2-5]" \
			 nokeepalive ssl-unclean-shutdown \
			 downgrade-1.0 force-response-1.0

	CustomLog "${SRVROOT}/logs/ssl_request.log" \
			  "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

Adding New Websites

Open hosts file in C:\Windows\System32\drivers\etc\hosts to point new domain name to localhost:

127.0.0.1	mongooseandmink.local

Add Virtual Host on localhost homepage for http.

Add Virtual Host on https by opening up C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-ssl.conf and add:

<VirtualHost mongooseandmink.local:443>
 
	DocumentRoot "D:/sites/ouioui"
	ServerName mongooseandmink.local:443
	ServerAlias mongooseandmink.local
	ServerAdmin info@christinewilson.ca
	ErrorLog "${SRVROOT}/logs/error.log"
	TransferLog "${SRVROOT}/logs/access.log"

	SSLEngine on
	SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
	SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

	<FilesMatch "\.(cgi|shtml|phtml|php)$">
		SSLOptions +StdEnvVars
	</FilesMatch>

	<Directory "D:/sites/ouioui">
		SSLOptions +StdEnvVars
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		Require all granted
		AllowOverride All
	</Directory>

	BrowserMatch "MSIE [2-5]" \
			 nokeepalive ssl-unclean-shutdown \
			 downgrade-1.0 force-response-1.0

	CustomLog "${SRVROOT}/logs/ssl_request.log" \
			  "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

Websites with Old WordPress Database

For WordPress websites with old database (URL is localhost still), Update the htaccess to remove the folder

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /ouioui/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ouioui/index.php [L]
</IfModule>

Update wp-config file to use new domain name:

define( 'WP_HOME', 'http://mongooseandmink.local/' );
define( 'WP_SITEURL', 'http://mongooseandmink.local/' );

Setting Up Free Custom Domain Email Addresses with GoDaddy and Gmail (2019 Edition)

Recently I went into the rats nest that is GoDaddy’s dashboard to setup a free email forwarding address for a side project. I found it fairly impossible. Thus leads me to this post.

Here is how to do this in the 2019 version of GoDaddy’s dashboard and Gmail. It will take you about 30 minutes. Just do all the things I say and you’ll get out alive.

Here we go…

  1. Visit your GoDaddy dashboard here. Go to the ‘My Products’ section.
  2. Scroll all the way down past your domains, and expand the Additional Products section. (this took me forever to find be grateful).
  3. Click on the ‘Redeem’ button next to Email Forwarding. In the dropdown window, select the domain you’d like a forwarding email address for and click the button to redeem the ‘100 pack.’
  4. Scroll up to the Workspace Email section and click on Options next to the 100 pack. Don’t click on ‘Sign It’ it won’t work if you don’t have another email with GoDaddy.
  5. Click on the hilariously tiny ‘Launch Control Center’ button in the top right. Yeah, GoDaddy ain’t interested in you doing this in the least. They want your money not your love.
  6. Check your MX Records for this domain by clicking on Tools > Server Settings. If you’re MX Records are not yet setup (GoDaddy doesn’t do it for you), navigate to your DNS settings for this domain and add the two MX records below.
  7. Now, once you are in the Launch Control Center click on Create Forward in the menu bar.
  8. Enter the email address you want to create for your domain, and enter in the Gmail email address you want to forward that email to. You may want to go ahead and enable the ‘Catch All’ feature on this screen.
  9. Go into Gmail, and click into Settings. Go to the Accounts and Import section and click on:

    Enter the email address you want to forward, keep ‘Treat As Alias’ checked, and on the next screen fill it out like this:

    Username is your personal email address
    If you are like me, you’ll get this error:
  10. If you get the Less Secure Apps error, you have to go into your Security Settings in your Google Account. Google explains this more here but just follow my steps instead of reading that. The way I ended up being able to do it was by Enabling 2 Step Verification and then requesting a custom App Password.
  11. Enable 2 Step Verification by click on that setting in the Security section of your Google Account and following the Steps. Be sure to have your phone nearby.
  12. Once you’ve enabled 2-Step, your account won’t be able to interface with ‘Less Secure Apps’ with your normal password. So, go into App Passwords in your Google Account, and create a custom password for your Mail client.

    After clicking Generate you should then get a screen like this:
  13. Copy paste that password into the yellow screen back in Gmail.
  14. Pray to your version of a higher power.
  15. Hopefully it worked! If it did you will see this screen:
  16. Now all you need to do is click on the email link that Google just sent you to confirm your email, then you will be able to send email from your newly created forward address!

Set up new project on HQ Deploy

https://christine.deployhq.com/projects/new

  1. Choose Bitbucket and create project
  2. Choose your new repo you created
  3. Create Production Server
  4. Hostname:
    35.192.41.230
  5. Username:
    chris
  6. Check off ” Use SSH key rather than password for authentication? “
  7. Copy key, open Filezilla login with chris
  8. Go to .ssh/authorized_keys and copy file to desktop
  9. Open file and add new key. Upload back to server
  10. On FileZilla open theme folder in site and copy full path. Add to “Deployment Path”
  11. Click “Create Server”

You can now deploy master branch to website