Question 87 of 527
Create simple shell scriptshardMultiple ChoiceObjective-mapped

Quick Answer

The answer is a missing SSH agent environment in cron. The core issue is that cron executes jobs in a non-interactive, minimal shell that lacks the SSH_AUTH_SOCK variable and does not automatically load the SSH agent or its keys. When the script runs manually as root, the SSH agent is typically active and the private key is already added, but cron has no access to that agent socket, causing SSH to fail authentication—even though the known_hosts file is correct, the misleading “Host key verification failed” error actually stems from the inability to authenticate the key. On the Red Hat EX200 exam, this scenario tests your understanding of cron’s restricted environment versus interactive shells, and it’s a common trap where candidates focus on host keys instead of authentication. The best fix is to modify the script to explicitly specify the private key with `ssh -i /root/.ssh/id_rsa`, bypassing the agent entirely. Memory tip: “Cron has no agent—specify the key directly.”

EX200 Create simple shell scripts Practice Question

This EX200 practice question tests your understanding of create simple shell scripts. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

You are a system administrator for a medium-sized company running Red Hat Enterprise Linux 8 on all servers. The development team has created a shell script that is supposed to be run nightly via cron to synchronize configuration files from a master server to multiple web servers. The script is located at /opt/scripts/sync_configs.sh and is owned by root. It uses rsync over SSH with key-based authentication. The script works perfectly when run manually by root, but when it runs via cron, the synchronization fails with the error 'Host key verification failed.' The script does not explicitly specify any SSH options. The cron job is configured in /etc/crontab as: `0 2 * * * root /opt/scripts/sync_configs.sh`. The SSH keys are stored in /root/.ssh/id_rsa and the known_hosts file contains the correct host key for the master server. What is the most likely cause of the failure, and what is the best course of action to resolve it?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "best"

    Why it matters: Signals that multiple options may be partially correct. Choose the option that most directly solves the exact problem described, not the one that sounds most complete.

  • Clue: "most likely"

    Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

Question 1hardmultiple choice
Full question →

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

The cron environment lacks the SSH agent or the key is not loaded. Modify the script to use `ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no` or add a line to load the key via `ssh-add`.

D is correct because cron runs in a minimal environment that does not automatically load the SSH agent or add keys to it. When the script runs manually as root, the SSH agent is typically running and the key is loaded, but cron does not have access to the agent's socket. The error 'Host key verification failed' is misleading; the actual issue is that SSH cannot authenticate because the private key is not available to the agent, not that the host key is unknown. Adding `ssh -i /root/.ssh/id_rsa` explicitly specifies the key file, bypassing the need for an agent, or using `ssh-add` in the script loads the key into an agent for the cron session.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The PATH variable in cron does not include /usr/bin/rsync. Add a full path to rsync in the script or set PATH in the crontab.

    Why it's wrong here

    While PATH can be an issue, the error message specifically says 'Host key verification failed', not 'command not found'. So PATH is not the primary cause.

  • The script does not have execute permission for the root user. Run `chmod +x /opt/scripts/sync_configs.sh`.

    Why it's wrong here

    The script is owned by root and would have execute permission for root; cron runs as root, so permission is not the issue.

  • The known_hosts file in /root/.ssh/ contains an incorrect host key for the master server. Remove the entry and reconnect manually to update it.

    Why it's wrong here

    The host key verification fails because SSH is not using the known_hosts file, not because the key is wrong. The error suggests the key is not being accepted because the host key is not known (i.e., not found) due to environmental issues.

  • The cron environment lacks the SSH agent or the key is not loaded. Modify the script to use `ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no` or add a line to load the key via `ssh-add`.

    Why this is correct

    Cron does not have access to the SSH agent; explicitly specifying the private key and disabling strict host key checking (or adding the host key to known_hosts via script) resolves the issue.

    Clue confirmation

    The clue words "best", "most likely" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates see 'Host key verification failed' and immediately think the known_hosts file is wrong (option C), but the real issue is that cron lacks the SSH agent environment, causing the key to not be loaded, which leads to authentication failure that manifests as a host key error.

Trap categories for this question

  • Command / output trap

    While PATH can be an issue, the error message specifically says 'Host key verification failed', not 'command not found'. So PATH is not the primary cause.

Detailed technical explanation

How to think about this question

Under the hood, SSH key-based authentication requires the private key to be accessible to the SSH client. When using an SSH agent, the agent holds the decrypted key in memory and communicates via a Unix domain socket pointed to by the SSH_AUTH_SOCK environment variable. Cron does not inherit this variable, so the agent is unavailable. The `-i` option directly specifies the private key file, which SSH reads without needing an agent. The 'Host key verification failed' error can also occur if the host key is not in known_hosts, but here the known_hosts is correct; the misleading error arises because SSH fails to authenticate and then fails to verify the host key in some edge cases, but the root cause is the missing key.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A small business has 20 workstations on the 192.168.1.0/24 network and one public IP from its ISP. The router uses PAT (NAT overload) so all 20 devices share one public address using different source ports. NAT questions test whether you understand the four address terms and which direction each translation applies.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related EX200 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free EX200 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this EX200 question test?

Create simple shell scripts — This question tests Create simple shell scripts — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: The cron environment lacks the SSH agent or the key is not loaded. Modify the script to use `ssh -i /root/.ssh/id_rsa -o StrictHostKeyChecking=no` or add a line to load the key via `ssh-add`. — D is correct because cron runs in a minimal environment that does not automatically load the SSH agent or add keys to it. When the script runs manually as root, the SSH agent is typically running and the key is loaded, but cron does not have access to the agent's socket. The error 'Host key verification failed' is misleading; the actual issue is that SSH cannot authenticate because the private key is not available to the agent, not that the host key is unknown. Adding `ssh -i /root/.ssh/id_rsa` explicitly specifies the key file, bypassing the need for an agent, or using `ssh-add` in the script loads the key into an agent for the cron session.

What should I do if I get this EX200 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "best", "most likely". Signals that multiple options may be partially correct. Choose the option that most directly solves the exact problem described, not the one that sounds most complete.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This EX200 practice question is part of Courseiva's free Red Hat certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the EX200 exam.