0
0
Bash Scriptingscripting~10 mins

SSH automation in Bash Scripting - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to connect to a remote server using SSH.

Bash Scripting
ssh [1]@example.com
Drag options to blanks, or click blank then click option'
Auser
Bpassword
Croot
Dlocalhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'password' instead of username in the SSH command.
Using 'localhost' which connects to the local machine, not remote.
2fill in blank
medium

Complete the code to run a command remotely over SSH.

Bash Scripting
ssh user@example.com '[1]'
Drag options to blanks, or click blank then click option'
Als -l
Bcd /home
Cmkdir new_folder
Dexit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'exit' which closes the SSH session instead of running a command.
Using 'cd /home' which changes directory but does not produce output.
3fill in blank
hard

Fix the error in the SSH command to copy a file from local to remote.

Bash Scripting
scp [1] user@example.com:/home/user/
Drag options to blanks, or click blank then click option'
Aexample.com
B/home/user/file.txt
Cuser@file.txt
Dfile.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Adding user or host before the local file name causes errors.
Using a remote path as the source file.
4fill in blank
hard

Fill both blanks to create an SSH key pair and copy the public key to the remote server.

Bash Scripting
ssh-keygen -t [1] -f ~/.ssh/id_[2] -N ''
Drag options to blanks, or click blank then click option'
Arsa
Bdsa
Ced25519
Decdsa
Attempts:
3 left
💡 Hint
Common Mistakes
Using outdated key types like 'dsa'.
Mismatching key type and file name.
5fill in blank
hard

Fill all three blanks to copy the SSH public key to the remote server for passwordless login.

Bash Scripting
cat ~/.ssh/id_[1].pub | ssh [2]@example.com 'mkdir -p ~/.ssh && cat >> ~/.ssh/[3]'
Drag options to blanks, or click blank then click option'
Arsa
Buser
Cauthorized_keys
Ded25519
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong key file name.
Using wrong remote username.
Appending to wrong file instead of 'authorized_keys'.