Bird
Raised Fist0
Linux CLIscripting~5 mins

Key-based authentication in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is key-based authentication in SSH?
Key-based authentication uses a pair of cryptographic keys (a private key and a public key) to securely log into a remote server without typing a password.
Click to reveal answer
beginner
What command generates an SSH key pair?
The command ssh-keygen creates a new SSH key pair (private and public keys) on your local machine.
Click to reveal answer
beginner
Where should the public key be placed on the remote server for key-based authentication?
The public key should be added to the ~/.ssh/authorized_keys file in the user's home directory on the remote server.
Click to reveal answer
beginner
Why is it important to keep the private key secure?
The private key is like a secret password. If someone else gets it, they can access your servers without permission. So, it must be kept private and protected.
Click to reveal answer
intermediate
How does key-based authentication improve security compared to password authentication?
It avoids sending passwords over the network, uses strong cryptography, and can be combined with passphrases for extra protection, making it harder for attackers to gain access.
Click to reveal answer
Which file on the remote server stores the public keys allowed for SSH login?
A~/.ssh/authorized_keys
B~/.ssh/id_rsa
C~/.ssh/config
D~/.ssh/known_hosts
What command do you use to create a new SSH key pair?
Assh-copy-id
Bssh-keygen
Cssh-add
Dssh-agent
Which key must you keep secret to maintain security in key-based authentication?
APublic key
BAuthorized key
CPrivate key
DHost key
What is the main benefit of using key-based authentication over password authentication?
AIt disables SSH login
BIt uses weaker encryption
CIt requires less disk space
DNo need to type a password each time
Which command copies your public key to a remote server for easy setup?
Assh-copy-id
Bscp
Cssh-add
Dssh-keygen
Explain the steps to set up key-based authentication for SSH login.
Think about creating keys, placing the public key on the server, and connecting.
You got /4 concepts.
    Why is key-based authentication considered more secure than password authentication?
    Consider what happens when you use keys instead of typing passwords.
    You got /4 concepts.

      Practice

      (1/5)
      1. What is the main purpose of key-based authentication in SSH?
      easy
      A. To encrypt files on the local computer
      B. To allow secure login without typing a password every time
      C. To speed up the internet connection
      D. To create a backup of the server data

      Solution

      1. Step 1: Understand key-based authentication

        Key-based authentication uses a pair of keys to allow login without passwords.
      2. Step 2: Identify the main benefit

        This method lets users connect securely without typing passwords each time.
      3. Final Answer:

        To allow secure login without typing a password every time -> Option B
      4. Quick Check:

        Key-based authentication = passwordless secure login [OK]
      Hint: Key-based auth means no password typing needed [OK]
      Common Mistakes:
      • Confusing key-based auth with file encryption
      • Thinking it speeds up internet
      • Believing it backs up data
      2. Which command correctly generates a new SSH key pair?
      easy
      A. ssh-keygen
      B. ssh-copy-id
      C. ssh-add
      D. ssh-connect

      Solution

      1. Step 1: Identify the key generation command

        The command ssh-keygen creates a new SSH key pair.
      2. Step 2: Differentiate from other commands

        ssh-copy-id copies keys, ssh-add adds keys to agent, ssh-connect is invalid.
      3. Final Answer:

        ssh-keygen -> Option A
      4. Quick Check:

        Generate keys = ssh-keygen [OK]
      Hint: ssh-keygen always creates keys [OK]
      Common Mistakes:
      • Using ssh-copy-id to generate keys
      • Confusing ssh-add with key creation
      • Typing a non-existent ssh-connect command
      3. What will happen if you run ssh-copy-id user@server after generating your SSH keys?
      medium
      A. The SSH service on the server restarts
      B. Your private key is copied to the server
      C. The server's keys are copied to your local machine
      D. Your public key is copied to the server for passwordless login

      Solution

      1. Step 1: Understand ssh-copy-id purpose

        This command copies your public key to the server's authorized keys file.
      2. Step 2: Identify what is copied

        Only the public key is copied, enabling passwordless login; private keys stay local.
      3. Final Answer:

        Your public key is copied to the server for passwordless login -> Option D
      4. Quick Check:

        ssh-copy-id copies public key to server [OK]
      Hint: ssh-copy-id copies public key, not private [OK]
      Common Mistakes:
      • Thinking private key is copied
      • Believing server keys copy locally
      • Assuming ssh-copy-id restarts SSH
      4. You tried to connect with SSH key authentication but still get a password prompt. Which is the most likely cause?
      medium
      A. The public key was not copied to the server
      B. The private key file is missing on the server
      C. The SSH server is turned off
      D. The username is incorrect

      Solution

      1. Step 1: Check key placement

        If the public key is not on the server, SSH cannot authenticate without a password.
      2. Step 2: Understand private key location

        The private key stays on the client, so missing it on the server is irrelevant.
      3. Final Answer:

        The public key was not copied to the server -> Option A
      4. Quick Check:

        Missing public key on server = password prompt [OK]
      Hint: Public key must be on server for key login [OK]
      Common Mistakes:
      • Looking for private key on server
      • Assuming SSH server off causes password prompt
      • Blaming wrong username without checking keys
      5. You want to automate SSH login to multiple servers without passwords. Which sequence of commands is correct?
      hard
      A. ssh user@server -> ssh-copy-id user@server -> ssh-keygen
      B. ssh-copy-id user@server -> ssh-keygen -> ssh user@server
      C. ssh-keygen -> ssh-copy-id user@server -> ssh user@server
      D. ssh user@server -> ssh-keygen -> ssh-copy-id user@server

      Solution

      1. Step 1: Generate SSH keys first

        Use ssh-keygen to create your key pair locally.
      2. Step 2: Copy public key to server

        Use ssh-copy-id user@server to add your public key to the server.
      3. Step 3: Connect without password

        Now ssh user@server logs in using the key without asking for a password.
      4. Final Answer:

        ssh-keygen -> ssh-copy-id user@server -> ssh user@server -> Option C
      5. Quick Check:

        Generate keys, copy key, then connect [OK]
      Hint: Generate keys first, then copy, then connect [OK]
      Common Mistakes:
      • Copying keys before generating them
      • Trying to connect before copying keys
      • Mixing command order
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard