0
0
Linux CLIscripting~20 mins

SSH key generation (ssh-keygen) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SSH Key Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this ssh-keygen command?
You run the command ssh-keygen -t rsa -b 2048 -f mykey -N "" in a Linux terminal. What output will you see immediately after?
Linux CLI
ssh-keygen -t rsa -b 2048 -f mykey -N ""
AError: Invalid option -b 2048
Bssh-keygen: command not found
C
Generating public/private rsa key pair.
Your identification has been saved in mykey.
Your public key has been saved in mykey.pub.
The key fingerprint is:
SHA256:... user@hostname
The key's randomart image is:
+---[RSA 2048]----+
| .o+o.           |
|.o=+o            |
|+o+o             |
|=+o              |
|.o.              |
|                 |
|                 |
|                 |
|                 |
+----[SHA256]-----+
D
Generating DSA key pair.
Your identification has been saved in mykey.
Your public key has been saved in mykey.pub.
Attempts:
2 left
💡 Hint
Think about what ssh-keygen outputs when generating an RSA key with no passphrase.
💻 Command Output
intermediate
2:00remaining
What error does this ssh-keygen command produce?
You run ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N without specifying a passphrase value. What error message appears?
Linux CLI
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N
APermission denied: cannot write to ~/.ssh/id_ed25519
B
Generating public/private ed25519 key pair.
Your identification has been saved in ~/.ssh/id_ed25519.
CError: Unknown key type ed25519
D
ssh-keygen: option requires an argument -- 'N'
Usage: ssh-keygen [options]
Attempts:
2 left
💡 Hint
The -N option requires a passphrase argument, even if empty.
📝 Syntax
advanced
2:00remaining
Which ssh-keygen command correctly generates a 4096-bit RSA key with a comment?
Select the command that generates a 4096-bit RSA key with the comment 'admin@example.com' and saves it to 'admin_rsa'.
Assh-keygen -t rsa -b 4096 -C admin@example.com -f admin_rsa
Bssh-keygen -t rsa -b 4096 -comment admin@example.com -file admin_rsa
Cssh-keygen --type rsa --bits 4096 --comment 'admin@example.com' --file admin_rsa
Dssh-keygen -type rsa -bits 4096 -C 'admin@example.com' -f admin_rsa
Attempts:
2 left
💡 Hint
Check the correct ssh-keygen option names for comment and file.
🚀 Application
advanced
2:00remaining
How to automate ssh-keygen to generate a key without prompts?
You want to write a script that generates an ed25519 SSH key named 'deploy_key' with no passphrase and no user interaction. Which command achieves this?
Assh-keygen -t ed25519 -f deploy_key
Bssh-keygen -t ed25519 -f deploy_key -N "" -q
Cssh-keygen -t ed25519 -f deploy_key -P ""
Dssh-keygen -t ed25519 -f deploy_key -n
Attempts:
2 left
💡 Hint
Use options to suppress prompts and specify empty passphrase.
🧠 Conceptual
expert
2:00remaining
What is the effect of the -o option in ssh-keygen?
You run ssh-keygen -t rsa -b 2048 -o -f keyfile. What does the -o option do?
AIt saves the private key using the new OpenSSH format instead of the older PEM format.
BIt overwrites the existing keyfile without asking for confirmation.
CIt outputs the public key to standard output instead of a file.
DIt optimizes the key generation speed by using fewer random bytes.
Attempts:
2 left
💡 Hint
Think about key file formats and security improvements.