Is a Private Key on a Linux Client Used in SSH Authentication to a Remote Server?

Question
This website (https://kb.iu.edu/d/aews) says "On the SSH command line: Add the -i flag and the path to your private key."

When running an SSH command, you do not think that the client's private key would not come into play. You think that the public key would be used. The man page for SSH says

-i identity_file
Selects a file from which the identity (private key) for public key authentication is read
…
ssh will also try to load certificate information from the filename obtained by appending -cert.pub to identity filenames.

You think that identity_files are public keys, and the website that you mentioned above is incorrect. Does this -i flag allow a user to denote a public key?

Answer
No, the -i flag denotes a private key. The man page and the link above are correct. The private key does come into play when using an SSH command.

Page 166 of SSH, The Secure Shell: The Definitive Guide version 1 explains that the identity file is a private key. For various reasons this private key is used when authenticating via SSH to a remote server.

Terraform: Up & Running, 2nd Edition by Yevgeniy Brikman (O'Reilly), Copyright 2019, 978-1-492-04690-5 (page 214) says that the authorized_keys file on a Linux server that is an EC-2 instance will have the public key of an SSH pair. To access this server your client would need to have the private key that corresponds to the public key on the server.

FFR
The convention for a private key's name is often the same, except the public key has a .pub extension. https://superuser.com/questions/232362/how-to-convert-ppk-key-to-openssh-key-under-linux

How Do You Log Out of cj.com (aka Commission Junction)?

Problem scenario
You have logged into the CJ website. You want to log out. What do you do?

Solution
Click your name/company name in the upper right hand corner. You should see "Login Manager", "Privacy Policy", "© Commission Junction LLC". Underneath those three things there is a light gray bar that may almost blend in with the background. It says "Logout" in possibly faint gray (medium gray) letters. It looks like this:

How Do You List the ELBs in Your AWS Account when You Know One Exists But the Command You Run Shows None?

Problem scenario
You run an AWS CLI command to list load balancers. It returns none. You know there are load balancers. What should you do?

Solution
Run these commands:

aws elb describe-load-balancers
aws elbv2 describe-load-balancers

(It could be that you have a newer load balancer or an older style load balancer. If you run both of the above commands, you should find it.)

What is a Bootstrap DNS Server?

Question
What is a bootstrap DNS server? When is a bootstrap DNS server needed?

Answer
In computing the term "bootstrap" can mean to initiate a self-sustaining process (the source is this posting). A bootstrap DNS server is a DNS server that allows other domain name entries (such non-IP addresses) to be found by finding a DNS server. If you have hostnames in an /etc/hosts file or similar configuration, the bootstrap DNS server maps and routes hostnames to IP addresses initially (such as to other regular DNS servers). Similar to how /etc/resolv.conf works to point a host server to a specific DNS server, the bootstrap DNS server resolves various entries of hostnames to IP addresses when such hostnames would otherwise not be resolved, mapped or found.

A bootstrap DNS server is needed for a given pod or server for the initial resolution/finding of hostnames that are themselves DNS servers but need mapping from the pod or server. Thus a bootstrap DNS server allows regular DNS to be configured when regular IP address routing is insufficient (e.g., for the first time a server or pod comes online).

For more information, see these postings:

How Do You Find What GUI/Desktop Environment Your Linux Server Is Using?

Problem scenario
There is a GUI desktop environment that your Linux machine is using. You want to know which one it is. What do you do?

Possible Solution #1
Run these commands:
sudo ps -ef | grep gnome
env | grep -i xdg

Possible Solution #2
echo $XDG_CURRENT_DESKTOP
echo $DESKTOP_SESSION

(Taken from https://unix.stackexchange.com/questions/46305/is-there-a-way-to-retrieve-the-name-of-the-desktop-environment)

Possible Solution #3
This command may give you clues if it is gnome: whereis gnome

Possible Solution #4
In the desktop GUI, go to Systems Tools or YAST (or some Control Panel equivalent) and go to "About". It may say there.

Possible Solution #5
apt list --installed | grep gnome
sudo yum list installed | grep gnome
sudo zypper se | grep gnome

If you suspect something other than Gnome is installed, see this page for other choices: https://en.wikipedia.org/wiki/Desktop_environment

How Do You Print Out Aggregate Cryptocurrency Information Based on a Date Range?

Problem scenario
You want to print out the average cryptocurrency price along with the minimum and maximum prices based on a range of dates. What do you do?

Solution
This solution only goes back to 2015 for BTC. For other cryptocurrencies, the oldest price data is usually more recent than that.

Prerequisite
This assumes you have installed pandas: pip install pandas
If you need assistance installing pip, see this posting.

Procedures
Run this Python program; you may change the exchange to the one of your choice, the currency symbols to the cryptocurrency symbol of your choice, and the "to_symbol" to the currency of your choice.

"""
Written in March of 2021 by www.continualintegration.com

It was adapted from these postings:
https://towardsdatascience.com/cryptocurrency-analysis-with-python-buy-and-hold-c3b0bc164ffa
https://towardsdatascience.com/cryptocurrency-analysis-with-python-macd-452ceb251d7c?gi=12b983021ac2


"""

import pandas as pd
import requests
from datetime import datetime

def get_filename(from_symbol, to_symbol, exchange, datetime_interval, download_date):
    return '%s_%s_%s_%s_%s.csv' % (from_symbol, to_symbol, exchange, datetime_interval, download_date)

def download_data(from_symbol, to_symbol, exchange, datetime_interval):
    supported_intervals = {'minute', 'hour', 'day'}
    print('Downloading %s trading data for %s %s from %s' %
          (datetime_interval, from_symbol, to_symbol, exchange))
    base_url = 'https://min-api.cryptocompare.com/data/histo'
    url = '%s%s' % (base_url, datetime_interval)    
    params = {'fsym': from_symbol, 'tsym': to_symbol,
              'limit': 2000, 'aggregate': 1,
              'e': exchange}
    request = requests.get(url, params=params)
    data = request.json()
    return data

def convert_to_dataframe(data):
    df = pd.json_normalize(data, ['Data'])
    df['datetime'] = pd.to_datetime(df.time, unit='s')
    df = df[['datetime', 'low', 'high', 'open',
             'close', 'volumefrom', 'volumeto']]
    return df

def filter_empty_datapoints(df):
    indices = df[df.sum(axis=1) == 0].index
    print('Filtering %d empty datapoints' % indices.shape[0])
    df = df.drop(indices)
    return df

def file_creator(from_symbol, to_symbol, exchange, datetime_interval):
    data = download_data(from_symbol, to_symbol, exchange, datetime_interval)
    df = convert_to_dataframe(data)
    df = filter_empty_datapoints(df)
    latest_date = datetime.now().date().isoformat() 
    filename = get_filename(from_symbol, to_symbol, exchange, datetime_interval, latest_date)
    #print('Saving data to %s' % filename)
    print('The oldest day in the range obtained for ' + from_symbol + ' was ' + str(df['datetime'].min()))
    df.to_csv(filename, index=False)


def get_filename(from_symbol, to_symbol, exchange, datetime_interval, download_date):
    return '%s_%s_%s_%s_%s.csv' % (from_symbol, to_symbol, exchange, datetime_interval, download_date)

def read_dataset(filename):
    #print('Reading data from %s' % filename)
    df = pd.read_csv(filename)
    df.datetime = pd.to_datetime(df.datetime) # change to datetime
    df = df.set_index('datetime') 
    df = df.sort_index() # sort by datetime
    #print(df.shape)
    return df

print("This prints out aggregated data for certain cryptocurrencies.  It downloads files first.")

from_symbol = 'BTC'
to_symbol = 'USD'
exchange = 'Coinbase'      # "Bitstamp" and "Coinbase" are valid among others.
datetime_interval = 'day'
file_creator(from_symbol, to_symbol, exchange, datetime_interval)

from_symbol = 'ETH'
file_creator(from_symbol, to_symbol, exchange, datetime_interval)

from_symbol = 'LTC'
file_creator(from_symbol, to_symbol, exchange, datetime_interval)

latest_date = datetime.now().date().isoformat() 
df_btc = read_dataset(get_filename('BTC', to_symbol, exchange, datetime_interval, latest_date))
df_eth = read_dataset(get_filename('ETH', to_symbol, exchange, datetime_interval, latest_date))
df_ltc = read_dataset(get_filename('LTC', to_symbol, exchange, datetime_interval, latest_date))

df = pd.DataFrame({'BTC': df_btc.close,
                   'ETH': df_eth.close,
                   'LTC': df_ltc.close}) 

print(" ")

print(df.describe())

If you want to receive free cryptocurrency by just learning more, try Coinbase; it is ideal for Americans. For Europeans, the platform/company Iconomi.com can allow you to buy crypto or learn more.

How Do You Write a Palindrome Testing Program in Python That Ignores Punctuation and Spaces?

Problem scenario
You want to write a palindromic testing program without importing any modules that ignores a string's punctuation or spaces. What do you do?

Solution
Use this program:

def is_palindrome(s: str) -> bool:
    # i moves forward, and j moves backward
    i, j = 0, len(s) -1
    while i < j:
        while not s[i].isalnum() and i < j:
            i += 1
        while not s[j].isalnum() and i < j:
            j -= 1
        if s[i].lower() != s[j].lower():
            return False
        i, j = i + 1, j - 1
    return True

# The above lines of code were taken from page 78 of Elements of Programming Interviews in Python.

print(is_palindrome("aaaabaabaa"))

To buy the cited book, click here.

What Are The Differences between Built-In Commands, Utilities, System Calls and Non-System Calls?

Question
You want to know what the differences are between built-ins, utilities, system calls and non-system calls. What are some examples of these?

Answer
You can break down the answer into four categories of Linux commands. You have commands that are either built-ins or utilities. You have commands that are either system calls or they are not. Here is a diagram for four types of commands and their examples:

BuiltinsUtilities
System Callschown, kill, umaskmkdir, stat
Non-system Callsechonmap

What Do You Do If There is Play in the Handlebars of Your Folding Bike?

Problem scenario
You have a collapsible bicycle (for commuting in a big city), and the handle bars have play in them. What should you do?

Solution
Verify the mechanism for securing the bike in "riding mode" is in place. Some folding bikes have latches that help secure the handle bars in place. If you forgot a step like this, there could be play. This play is a concern if it has had a previous owner or is an older bike.

If you are not 100% sure that there is movement, try extending the handle bars to a higher than normal point. Then ride and push around on the handlebars to see if there is movement. This puts more torque on the handlebar assembly with the stem elongated. This is a sanity check, but with higher handle bars (as folding bikes usually have adjustable height handlebars) can help pronounce/exaggerate the movement in the handlebars themselves. You want to confirm that the movement is real unless you know there is movement that shouldn't happen. This is a very bad sign.

We strongly recommend you take your bike to a bike store to have it looked at by a professional. Even then if the hinges are worn there may be no tightening they can do. Some bike mechanics may think that tightening is only done with newer hinges; this is not necessarily true for older and newer folding bikes. The shaky handlebars could be from something other than the hinges. There can be a component relatively invisible in normal use -- even during the folding down process -- that is the culprit. The lateral movement or lack of stiffness (aka "play") is a very bad sign. We recommend not riding such a bike. Some people don't think affordable new folding bikes are worth the money, but these bikes can be cheap bran new without worn hinges or corroded interior components. Other people recommend used bikes that are from a high quality manufacturer if your budget is below $400-$500. Unfortunately used bikes that are old can have play in the handle bars and the handlebars can break when you are riding. It can be catastrophic. The free movement of the handlebars is the last warning sign before they can suddenly brake off. Your best best is to buy a new folding bike -- even a cheap one -- before risking such an accident.