Bird
Raised Fist0
Linux CLIscripting~20 mins

SSH connection basics in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
SSH Connection 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 command?
You run the command ssh -v user@192.168.1.10 to connect to a server. Which of the following lines will you see in the verbose output indicating a successful key exchange?
Linux CLI
ssh -v user@192.168.1.10
APermission denied (password).
Bdebug1: Authentication succeeded (publickey).
Cssh: Could not resolve hostname 192.168.1.10: Name or service not known
DConnection timed out during banner exchange
Attempts:
2 left
💡 Hint
Look for messages that confirm authentication success in verbose SSH output.
🧠 Conceptual
intermediate
1:30remaining
Which SSH option disables strict host key checking?
You want to connect to a new SSH server without being prompted to confirm the server's fingerprint. Which SSH option disables this prompt?
A-o PasswordAuthentication=no
B-o UserKnownHostsFile=/dev/null
C-o StrictHostKeyChecking=no
D-o ConnectTimeout=5
Attempts:
2 left
💡 Hint
This option controls whether SSH asks to confirm the server's fingerprint.
🔧 Debug
advanced
2:00remaining
Why does this SSH command fail with 'Permission denied'?
You run ssh user@host but get Permission denied (publickey,password). error. Which of the following is the most likely cause?
AThe SSH server does not allow password authentication and your public key is not set up.
BThe SSH client is using the wrong port number.
CThe SSH server is down and unreachable.
DThe username is misspelled in the command.
Attempts:
2 left
💡 Hint
Consider what authentication methods the server accepts and what keys you have.
🚀 Application
advanced
2:00remaining
How to copy a file securely using SSH?
You want to copy a file named report.txt from your local machine to the remote server server.example.com under the directory /home/user/docs. Which command correctly does this?
Ascp report.txt user@server.example.com:/home/user/docs/
Bssh user@server.example.com cp report.txt /home/user/docs/
Cssh-copy-id report.txt user@server.example.com:/home/user/docs/
Drsync report.txt user@server.example.com:/home/user/docs/
Attempts:
2 left
💡 Hint
Think about which command is designed to copy files over SSH.
💻 Command Output
expert
2:30remaining
What is the output of this SSH command with a custom port?
You run ssh -p 2222 user@host but get the error message. Which option shows the exact error you will see if port 2222 is closed on the server?
Linux CLI
ssh -p 2222 user@host
AConnection timed out during banner exchange
Bssh: Could not resolve hostname host: Name or service not known
CPermission denied (publickey).
Dssh: connect to host host port 2222: Connection refused
Attempts:
2 left
💡 Hint
Think about what happens when the port is closed but the host is reachable.

Practice

(1/5)
1. What does the command ssh user@hostname do?
easy
A. Lists files on the remote computer.
B. Copies files from the remote computer to local.
C. Starts a secure connection to the remote computer as 'user'.
D. Deletes the user account on the remote computer.

Solution

  1. Step 1: Understand the ssh command purpose

    The ssh command is used to securely connect to another computer over a network.
  2. Step 2: Analyze the syntax ssh user@hostname

    This syntax means connect as 'user' to the computer identified by 'hostname'.
  3. Final Answer:

    Starts a secure connection to the remote computer as 'user'. -> Option C
  4. Quick Check:

    ssh user@hostname = Secure connection [OK]
Hint: ssh user@host means connect securely as user [OK]
Common Mistakes:
  • Thinking ssh copies files instead of connecting
  • Confusing ssh with file listing commands
  • Assuming ssh deletes accounts
2. Which of these is the correct syntax to connect to a remote server with ssh?
easy
A. ssh user@hostname
B. ssh -connect user hostname
C. ssh connect user@hostname
D. ssh user hostname

Solution

  1. Step 1: Recall ssh command syntax

    The correct syntax is ssh user@hostname without extra words or flags for basic connection.
  2. Step 2: Check each option

    Options A, B, and D have incorrect syntax or missing '@' sign.
  3. Final Answer:

    ssh user@hostname -> Option A
  4. Quick Check:

    Correct ssh syntax = ssh user@hostname [OK]
Hint: ssh always uses user@hostname format [OK]
Common Mistakes:
  • Adding extra words like 'connect' in command
  • Omitting '@' between user and hostname
  • Using flags incorrectly for basic ssh
3. What will happen if you run ssh alice@192.168.1.10 and the password is correct?
medium
A. You will see a list of files on your local computer.
B. The remote computer will shut down.
C. Your local files will be deleted.
D. You will be logged into the remote computer as user alice.

Solution

  1. Step 1: Understand ssh login process

    Running ssh with user and IP tries to connect and log in to that remote machine.
  2. Step 2: Check what happens on correct password

    If password is correct, you get a command prompt on the remote machine as that user.
  3. Final Answer:

    You will be logged into the remote computer as user alice. -> Option D
  4. Quick Check:

    ssh + correct password = remote login [OK]
Hint: Correct password means remote login success [OK]
Common Mistakes:
  • Thinking ssh shuts down remote machine
  • Confusing ssh with file deletion
  • Assuming ssh lists local files
4. You try to connect with ssh bob@server.com but get the error: Permission denied (publickey). What is the likely problem?
medium
A. You typed the wrong hostname.
B. Your SSH key is missing or not accepted by the server.
C. The server is turned off.
D. You forgot to install ssh on your computer.

Solution

  1. Step 1: Understand the error message

    "Permission denied (publickey)" means the server expects an SSH key for authentication but did not accept yours.
  2. Step 2: Identify cause of error

    This usually means your SSH key is missing, not loaded, or not authorized on the server.
  3. Final Answer:

    Your SSH key is missing or not accepted by the server. -> Option B
  4. Quick Check:

    Permission denied (publickey) = SSH key issue [OK]
Hint: Permission denied (publickey) means SSH key problem [OK]
Common Mistakes:
  • Assuming hostname typo causes this error
  • Thinking server power state causes this error
  • Believing ssh must be installed locally to connect
5. You want to connect to a remote server at example.com as user admin but the server uses a non-standard port 2222. Which command will connect correctly?
hard
A. ssh -p 2222 admin@example.com
B. ssh admin@example.com:2222
C. ssh admin@example.com -port 2222
D. ssh admin@2222.example.com

Solution

  1. Step 1: Recall how to specify a port in ssh

    The correct flag to specify a port is -p followed by the port number.
  2. Step 2: Analyze each option

    ssh -p 2222 admin@example.com uses -p 2222 correctly. Options A, C, and D use incorrect syntax or wrong placement.
  3. Final Answer:

    ssh -p 2222 admin@example.com -> Option A
  4. Quick Check:

    Use -p to specify port in ssh [OK]
Hint: Use ssh -p port user@host for custom ports [OK]
Common Mistakes:
  • Putting port after hostname with colon
  • Using -port instead of -p
  • Changing hostname to include port number
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