Skip to content

Instantly share code, notes, and snippets.

@bwbaugh
Last active April 26, 2023 17:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwbaugh/2ba656e5b6feb6524364 to your computer and use it in GitHub Desktop.
Save bwbaugh/2ba656e5b6feb6524364 to your computer and use it in GitHub Desktop.
Guide to customize an Ubuntu EC2 instance.

Quick Start for Ubuntu EC2

Initial setup

Basic setup involves:

  • Install dotfiles.
  • Change the hostname.
  • Change the timezone.

Refer to the generic guide for additional common setup instructions e.g., configuring the default editor.

Install packages

Get the AWS CLI (github) to make it easier to interact with AWS services. It will use the instance profile.

sudo pip install awscli

Customize MOTD

Remove URLs

Remove some of the unneeded links in the MOTD by making (source):

sudo chmod -x /etc/update-motd.d/10-help-text /etc/update-motd.d/51-cloudguest

and add the --exclude-sysinfo-plugins=LandscapeLink option to the landscape-sysinfo command.

sudo vim /etc/update-motd.d/50-landscape-sysinfo

Add hostname

The dotfiles should have installed toilet (a fork of figlet). Dynamically generate text to show the hostname at login:

  1. Create a file for update-motd:

    sudo vim /etc/update-motd.d/10-hostname
    
  2. Add the following contents:

    #!/bin/sh
    
    echo
    echo
    toilet --filter crop $(hostname)
    echo
    
  3. Make the file executable:

    sudo chmod +x /etc/update-motd.d/10-hostname
    

Regenerate MOTD on connect

If you want the MOTD to be updated on every login (via SSH), instead of potentially showing information from the last login:

sudo vim /etc/pam.d/sshd

and comment out the noupdate portion of the command. For example:

Before:

session    optional     pam_motd.so  motd=/run/motd.dynamic noupdate

After:

session    optional     pam_motd.so  motd=/run/motd.dynamic # noupdate

The login file might also need to be updated, but this hasn't been tested:

sudo vim /etc/pam.d/login
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment