0
0
Linux CLIscripting~20 mins

SSH config file in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SSH Config Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of SSH config with Host alias
Given the following SSH config snippet, what is the output of ssh myserver if the server myserver.example.com is reachable and the user is alice?
Linux CLI
Host myserver
  HostName myserver.example.com
  User alice
  Port 2222
AConnects to myserver.example.com on port 2222 as user alice
BConnects to myserver.example.com on default port 22 as user alice
CConnects to myserver on default port 22 as current user
DFails with unknown host error
Attempts:
2 left
💡 Hint
Look at how HostName, User, and Port are set under the Host alias.
📝 Syntax
intermediate
2:00remaining
Identify the syntax error in SSH config
Which option shows a syntax error in this SSH config snippet?
AHost example\n HostName example.com\n Port 2200
BHost example\n HostName example.com\n User bob
CHost example\n HostName example.com\n User
DHost example\n HostName example.com\n IdentityFile ~/.ssh/id_rsa
Attempts:
2 left
💡 Hint
Check if all directives have values.
🔧 Debug
advanced
2:00remaining
Why does SSH ignore the Port setting?
Given this SSH config, why does ssh server1 connect on port 22 instead of port 2200?
Linux CLI
Host server1
  HostName server1.example.com
Host server*
  Port 2200
AThe wildcard Host block is ignored because it comes after the exact match
BThe first Host block overrides the Port setting because it matches exactly and has no Port line
CSSH always uses port 22 unless specified on the command line
DPort must be set before HostName to take effect
Attempts:
2 left
💡 Hint
SSH applies the first matching Host block and ignores later ones.
🚀 Application
advanced
2:00remaining
Create SSH config for multiple hosts with shared settings
You want to connect to web1.example.com and web2.example.com as user deploy on port 2222. Which SSH config snippet achieves this with minimal repetition?
AHost web1 web2\n HostName %h.example.com\n User deploy\n Port 2222
BHost web*\n HostName %h.example.com\n User deploy\n Port 2222
CHost web1\n HostName web1.example.com\n User deploy\n Port 2222\nHost web2\n HostName web2.example.com\n User deploy\n Port 2222
DHost web1 web2\n HostName web1.example.com\n User deploy\n Port 2222
Attempts:
2 left
💡 Hint
Use Host aliases and %h to substitute hostnames.
🧠 Conceptual
expert
2:00remaining
Effect of Include directive in SSH config
If your main SSH config file contains Include ~/.ssh/config.d/*, what happens when you run ssh myhost?
ASSH reads all files in ~/.ssh/config.d/ and applies their settings before the main config
BSSH reads the main config first, then applies settings from all included files in order
CSSH ignores the Include directive unless you specify --include on the command line
DSSH merges settings from included files with the main config, applying them in the order they appear
Attempts:
2 left
💡 Hint
Think about how SSH processes multiple config files.