disable host key checking

How to suppress typing “yes” when prompted by ssh. #!/bin/bash ssh-keygen -f "/home/user/.ssh/known_hosts" -R "yourdomain.com" ssh -o "StrictHostKeyChecking=no" -i "keys/key.pem" ubuntu@domain.com First remove old keys in the know_hosts file. Use “StrictHostKeyChecking” to suppress prompt.

February 9, 2020 · 1 min · ulysses

install go on linux mint 19.3

Here’s how to install Go on Ubuntu Linux Mint 19.3. Download the latest from https://golang.org/dl/. wget https://dl.google.com/go/go1.13.linux-amd64.tar.gz Check the checksum. sha256sum go1.13.linux-amd64.tar.gz Extract the Go tarball to the /usr/local directory. sudo tar -C /usr/local -xzf go1.13.linux-amd64.tar.gz Edit your Bash profile to add Go’s path. cd ~ vim ~/.profile # Add Go's path export PATH=$PATH:/usr/local/go/bin # Load the profile source ~/.profile Check if Go is installed. go version Output. go version go1.13 linux/amd64

February 9, 2020 · 1 min · ulysses

python pythagorean theorem

Here’s a simple Python program that calculates the hypotenuse of a right angle triangle using the Pythagorean Theory. a2 + b2 = c2 #!/usr/local/bin/python3 import math print("================================================") print("This program will calculate pythagorean theorem.") print("================================================") side_A = float(input("Enter side A: ")) side_B = float(input("Enter side B: ")) def pythagoreamTherem(side_A, side_B): side_C = math.sqrt(side_A * side_A + side_B * side_B) return side_C side_C = pythagoreamTherem(side_A, side_B) print("") print("Side C is: " + "%.2f" % round(side_C,2)) print("") Output ...

February 9, 2020 · 1 min · ulysses

standard ssl policy

Here’s a standard template for SSL Apache found in /etc/apache2/sites-available/default-ssl.conf. <ifmodule mod_ssl.c=""> <virtualhost _default_:443=""> ServerAdmin your-email@your-domain.com ServerName www.yourdomain.com ServerName yourdomain.com DocumentRoot /var/www/your-domain.com ErrorLog /var/www/your-domain.com/log/error.log CustomLog /var/www/your-domain.com/log/access.log combined <directory> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </directory> SSLCertificateFile /etc/letsencrypt/live/your-domain.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/your-domain.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </virtualhost> </ifmodule> Enable SSL. # Enable SSL Module a2enmod ssl systemctl restart apache2.service # Enable SSL Apache Config a2ensite default-ssl systemctl restart apache2.service # Alternate way to restart. service apache2 restart

February 9, 2020 · 1 min · ulysses

display sequential write throughput

Here’s a dd command to display sequential write throughput from the command line. time dd if=/dev/zero of=/mounted_backup_volume/zero.raw bs=1M count=512 status=progress Output is. 512+0 records in 512+0 records out 536870912 bytes (537 MB) copied, 0.667813 s, 804 MB/s real 0m0.669s user 0m0.000s sys 0m0.359s

February 5, 2020 · 1 min · ulysses

replace spaces with comma

Here’s a simple sed command to replace multiple spaces into a comma delimited file. sample.txt one two three four The sed command. sed 's/ \+ /,/g' sample.txt > sample2.txt sample2.txt one,two three,four

February 4, 2020 · 1 min · ulysses

aws cli s3 recursive copy

Here’s how to copy multiple files recursively using AWS CLI. The S3 cp command by default only copies a single file. To copy multiple files, you have to use the –recursive option along with –exclude and –include. In this example, we will exclude every file, but include only files with a json extension. aws s3 cp /tmp/folder s3://bucket/folder \ --recursive --exclude "*" --include "*.json" The result: upload: ./abc.json to s3://bucket/folder/abc.json upload: ./xyz.json to s3://bucket/folder/xyz.json

February 2, 2020 · 1 min · ulysses

standard s3 policy

Here’s a standard S3 policy to grant an IAM user access to a bucket within an AWS account. User is allowed to add, update, and delete objects. These 3 actions s3:ListAllMyBuckets, s3:GetBucketLocation, and s3:ListBucket are the additional permissions required to access the console. Also, the s3:PutObjectAcl and the s3:GetObjectAcl actions are required to be able to copy, cut, and paste objects within the console. { "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":[ "s3:ListAllMyBuckets" ], "Resource":"arn:aws:s3:::*" }, { "Effect":"Allow", "Action":[ "s3:ListBucket", "s3:GetBucketLocation" ], "Resource":"arn:aws:s3:::examplebucket" }, { "Effect":"Allow", "Action":[ "s3:PutObject", "s3:PutObjectAcl", "s3:GetObject", "s3:GetObjectAcl", "s3:DeleteObject" ], "Resource":"arn:aws:s3:::examplebucket/*" } ] }

January 28, 2020 · 1 min · ulysses

wordpress permalinks not working

Here’s a couple of things you can do to check if WordPress permalinks is not working. Make sure .htaccess has the right permissions. Make sure a2enmod Apache module is enabled. Restart the Apache server. chmod 664 /var/www/domain.com/.htaccess a2enmod rewrite systemctl restart apache2

January 28, 2020 · 1 min · ulysses

set linux time zone

Here’s another way of setting Linux time zone. Check server time. # check server time date Change to local time. # set to local time rm /etc/localtime ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime Check server time again. # check server time again date

January 27, 2020 · 1 min · ulysses