Engineering Log - command sets to remember

The original concept of this blog was to provide a reference for myself as a go forward in technology:  


Here are some interesting "Tasks" that I learned and have been using.  This is the living blog post that I plan to keep updating as I go.

Ubuntu distro upgrade:

  • Upon the deployment of an Ubuntu server (22.10 --> 22.04 LTS) run the command: 
  • sudo do-release-upgrade

Setup SSH authentication using PKI on a new server deploy:

  • I started with setting the hosts file on my Mac to know the IP of the name I wanted to use.  This is optional because there may be a DNS A record for the computer you want to connect to already
  • Connect to the local console of the computer and log in.  ( I have a VM that is running this so I just connect to the console and login with the user account ubuntu)
  • Type sudo su - command to elevate to root privileges
  • Type nano /etc/ssh/sshd_config to edit and allow ssh access to the VM
  • Find and change the PasswordAuthentication no --> yes or uncomment it.
  • Find and change the PubkeyAuthentication yes
  • We need to verify the permissions on the files and directories 
    • the .ssh directory is hidden but should be rwx for the user ubuntu 
    • the file authorized_keys should be rw-
    • Restart the sshd service systemctl restart sshd
  • Test ssh to the computer ssh ubuntu@192.168.2.3 and login with the password
  • Exit the connection
  • On the client that will be connecting to the computer generate the ssh key pair 
    • ssh-keygen -t rsa -b 4096 
    • Enter the file for the keys (I usually leave them default)
    • Enter a passphrase for additional security
  • Verify the files are there ls ~/.ssh/id*
  • Copy the keys using ssh-copy-id ubuntu@192.168.2.3
    • Enter the Password and the keys are copied
  • Try logging in with ssh
    • ssh ubuntu@192.168.2.3

Setting up a static address using Ubuntu's Netplan configuration

https://linuxize.com/post/how-to-configure-static-ip-address-on-ubuntu-20-04/ 
  • Get the naming of your interfaces with ip link | grep 2
  • This displays the name of the interface in which mine is ens192 

  • On older Ubuntu OS's that have been upgraded start with clearing your interface settings 
    • ip addr ens192 flush
  • Next will be to disable the cloud init configuration.
  • If you look in the file /etc/netplan/50-cloud-init.yaml you will see the method to disable the cloud-init's network configuration. 
  • Create a file 99-disable-network-config.cfg with touch, or using nano within the /etc/cloud/cloud.cfg.d/ directory
  • In the file type, network: {config: disabled} using spaces and not using tabs
  • Save the file Ctrl-x -- Y in nano

Configuring the yaml for Netplan

  • Go to /etc/netplan and create a file named 01-netcfg.yaml 
  • Within the file use the syntax from man netplan as there is a LOT of options
  • Generally I use:
  • Once the yaml is created save it and make sure to either remove the original 50-cloud-init.yaml by renaming it mv 50-cloud-init.yaml 50-cloud-init.yml or comment the configuration items in the file (even though in the file it says that configurations will not retain through a reboot)
  • Type apply netplan to have the yaml file implemented 
  • Then type ip addr to verify the IP change

More to come...



Comments