0
0
Bash Scriptingscripting~20 mins

SSH automation in Bash Scripting - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SSH Automation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of SSH command with remote script
What is the output of this bash script that uses SSH to run a remote command?
Bash Scripting
ssh user@remotehost 'echo Hello from $(hostname)'
AHello from $(hostname)
Bssh: Could not resolve hostname remotehost: Name or service not known
CHello from localmachine
DHello from remotehost
Attempts:
2 left
💡 Hint
The command runs on the remote host, so hostname is evaluated there.
📝 Syntax
intermediate
2:00remaining
Correct SSH key usage in bash script
Which option correctly uses an SSH private key file to connect to a remote server in a bash script?
Assh --key ~/.ssh/id_rsa user@host
Bssh -i ~/.ssh/id_rsa user@host
Cssh -keyfile ~/.ssh/id_rsa user@host
Dssh -k ~/.ssh/id_rsa user@host
Attempts:
2 left
💡 Hint
The correct option uses the -i flag for identity file.
🔧 Debug
advanced
2:00remaining
Why does this SSH command fail?
This bash script tries to copy a file to a remote server using SSH and SCP but fails. Why? scp /local/path/file.txt user@remotehost:/remote/path/ Options:
AThe remote path does not exist or user has no write permission
BThe local file path is incorrect
CThe SSH server is not running on remotehost
DThe scp command syntax is invalid
Attempts:
2 left
💡 Hint
Check permissions and existence of remote directory.
🚀 Application
advanced
2:00remaining
Automate running multiple commands over SSH
You want to run these two commands on a remote server via SSH in one connection: 1. cd /var/log 2. ls -l Which option correctly does this in a bash script?
Assh user@host 'cd /var/log && ls -l'
Bssh user@host 'cd /var/log ls -l'
Cssh user@host 'cd /var/log; ls -l'
Dssh user@host 'cd /var/log | ls -l'
Attempts:
2 left
💡 Hint
Separate commands with semicolon or && to run sequentially.
🧠 Conceptual
expert
2:00remaining
Understanding SSH agent forwarding security
What is the main security risk of enabling SSH agent forwarding when automating remote commands?
AA compromised remote server can use your SSH keys to access other servers without your passphrase
BYour private key file is copied to the remote server
CYour SSH password is sent in plain text over the network
DAgent forwarding disables encryption of SSH traffic
Attempts:
2 left
💡 Hint
Agent forwarding allows remote servers to use your keys temporarily.