Want your server to greet you with a nice picture (ASCII/ANSI art) when you SSH in? This guide shows how to generate different-width ASCII art pieces and automatically show the best-fitting one on login.
- A terminal that supports ANSI escape sequences (most modern terminals do).
- SSH access to the server.
- A place on the server to store the ASCII art, e.g.
/usr/share/ascii-art.
- Convert your image(s) to ASCII/ANSI text at several widths (90, 120, 200, … up to 500).
- Put each width version into a folder named after that width.
- Install a small login script that detects the client width and prints the most appropriate file.
Use a generator that can output plain text with ANSI color codes, not PNG. Example: https://www.asciiart.eu/image-to-ascii (or similar).
Create multiple versions of the same image at different widths (recommended widths: 90, 120, 160, 200, 300, 400, 500). Save each version as a plain .txt file (ANSI color enabled if you want colored output).
Tips
- Test output in a terminal window sized to that width before saving.
- If your generator produces PNG only, look for the ANSI/text output option or try another generator.
Create a shared directory for everyone to use:
sudo mkdir -p /usr/share/ascii-art
sudo chown root:root /usr/share/ascii-art
sudo chmod 755 /usr/share/ascii-artCreate width folders and copy art in:
# from your local machine or server, example:
sudo mkdir -p /usr/share/ascii-art/{90,120,160,200,300,400,500}
sudo cp art-90.txt /usr/share/ascii-art/90/
sudo cp art-120.txt /usr/share/ascii-art/120/
# repeat for other widthsIf you want per-user art, put the same folder structure under a user home (e.g. ~/ascii-art), but the global path is cleaner for multi-user servers.
This prints a random file from the best matching width folder when a user logs in over SSH. It includes a safe fallback (choose the largest width ≤ client width; if none, choose the smallest available).
Paste this into /etc/profile for all users, or ~/.bashrc for only one user. Adjust ART_DIR if you used a different path.
# Pictured MOTD - put in /etc/profile or in ~/.bashrc
ART_DIR="/usr/share/ascii-art"
# Only show for interactive SSH sessions
if [ -n "$SSH_TTY" ] && [ -d "$ART_DIR" ]; then
cols=$(tput cols 2>/dev/null || echo 80)
# Get sorted list of available widths (numbers only)
widths=( $(ls "$ART_DIR" 2>/dev/null | sort -n) )
# find best width: largest width <= cols
best=""
for w in "${widths[@]}"; do
# ensure it's a number
if [[ "$w" =~ ^[0-9]+$ ]]; then
if [ "$w" -le "$cols" ]; then
best="$w"
fi
fi
done
# If nothing is <= cols, pick the smallest available width as fallback
if [ -z "$best" ] && [ ${#widths[@]} -gt 0 ]; then
best="${widths[0]}"
fi
if [ -n "$best" ] && [ -d "$ART_DIR/$best" ]; then
art_file=$(find "$ART_DIR/$best" -maxdepth 1 -type f | shuf -n 1)
if [ -f "$art_file" ]; then
cat "$art_file"
fi
fi
fiCreate many width folders quickly:
sudo mkdir -p /usr/share/ascii-art/{90,120,160,200,300,400,500}Check your current terminal width (locally or via SSH):
tput cols
# or remotely
ssh user@host 'tput cols'Test printing a specific art file:
cat /usr/share/ascii-art/200/art1.txt/usr/share/ascii-artshould be readable by all users (e.g.chmod -R 755).- Avoid putting files with sensitive content there.
- If you want only certain users to see art, store per-user copies under their home directories instead.
-
Use ANSI colored art for prettier output (ensure the generator produces ANSI).
-
Animate printing with
pv -qL 800to “type” the image, e.g.:pv -qL 800 "$art_file" -
Use
lolcatto rainbow-color text (if installed), but be careful—it may break ANSI color art.
- Art wraps or breaks: The art width is wider than the client columns. Generate a version closer to the client width or resize the client terminal.
- No art shows: Verify
ART_DIRexists and contains numeric-named subfolders. Check/etc/profilepermissions and whether your login shell reads/etc/profilefor your session. - Colors not showing: Your terminal might not support ANSI, or the file is lacking ANSI escape sequences. Test with a known ANSI sample.
- Generate art at widths you care about (90, 120, 160, 200, …). Save as
.txt. - Upload them to
/usr/share/ascii-art/<width>/. - Add the login script to
/etc/profile(or~/.bashrc). - SSH in and enjoy.