0
0
Linux CLIscripting~15 mins

SSH config file in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Configure SSH Connections Using an SSH Config File
📖 Scenario: You often connect to multiple remote servers using SSH. Typing long commands with usernames, hostnames, and ports every time is tiring. To make this easier, you can create an SSH config file that stores these details. This way, you can connect with a simple nickname.
🎯 Goal: Build an SSH config file with entries for two servers. Each entry will have a nickname, hostname, username, and port. This will let you connect easily using the nickname instead of full details.
📋 What You'll Learn
Create an SSH config file at ~/.ssh/config
Add two host entries with exact nicknames and details
Use correct indentation and syntax for SSH config
Verify the config by showing its content
💡 Why This Matters
🌍 Real World
SSH config files save time and reduce errors when connecting to many servers. They are used by system administrators, developers, and anyone managing multiple remote machines.
💼 Career
Knowing how to configure SSH connections is essential for IT support, DevOps, and software development roles that require secure remote access.
Progress0 / 4 steps
1
Create the SSH config file with the first host entry
Create a file called ~/.ssh/config and add a host entry with the nickname server1. Set the hostname to 192.168.1.10, username to admin, and port to 2222. Use the exact format shown below with proper indentation (one tab or 4 spaces).
Linux CLI
Need a hint?

Each host entry starts with Host nickname. The following lines must be indented and specify HostName, User, and Port.

2
Add a second host entry to the SSH config file
Add another host entry to the same ~/.ssh/config file. Use the nickname server2. Set the hostname to example.com, username to guest, and port to 2200. Keep the same indentation style as the first entry.
Linux CLI
Need a hint?

Remember to separate host entries with a blank line for readability. Use the same indentation for the second entry.

3
Set file permissions for the SSH config file
Set the permissions of the ~/.ssh/config file to 600 so only you can read and write it. Use the chmod command with the exact permission number.
Linux CLI
Need a hint?

Use chmod 600 ~/.ssh/config to restrict file access to yourself only.

4
Display the SSH config file content
Use the cat command to display the contents of the ~/.ssh/config file. This will confirm your entries are saved correctly.
Linux CLI
Need a hint?

Use cat ~/.ssh/config to see the file content in the terminal.