Script Valley
Linux & Bash for Developers
Networking & SSH Essentials/Assessment

Practice & Assessment

Test your understanding of Networking & SSH Essentials

Multiple Choice Questions

5
1

What is the purpose of `ssh-copy-id user@server`?

2

What does `ss -tlnp` show?

3

Which rsync flag is essential to check before using `--delete` on a production server?

4

What curl flag sends a POST request with a JSON body?

5

You enable ufw on a remote server without first running `sudo ufw allow ssh`. What happens?

Coding Challenges

1
1

Server Connectivity Checker

Write a script check_servers.sh that reads a list of server addresses from a file servers.txt (one host:port per line, e.g. google.com:443). For each entry the script must: (1) Parse host and port using IFS=: read, (2) Check if the port is reachable using timeout 3 bash -c "echo >/dev/tcp/HOST/PORT" (3) Print ONLINE in green-style text or OFFLINE in a distinguishing format, (4) Count and print total online vs offline at the end, (5) Exit 1 if any server is offline. Test with a mix of valid and invalid hosts. Expected output: per-server status lines and a final summary count. Time estimate: 25 minutes.

Medium

Mini Project

1

Automated Deployment Script via SSH

Write a deploy.sh script that deploys a local project directory to a remote server. It must: (1) Read configuration (REMOTE_HOST, REMOTE_USER, REMOTE_DIR, LOCAL_DIR) from a .env file using source, (2) Run rsync -avz --exclude='.git' --exclude='node_modules' with --dry-run first and ask for confirmation before proceeding, (3) After rsync, SSH into the remote and run a sequence of commands (cd to dir, git pull or echo 'deployed', restart a service via systemctl or a custom command), (4) Test connectivity with a ping or ssh pre-check before starting, (5) Log all operations to deploy_TIMESTAMP.log, (6) Use a trap to handle Ctrl+C cleanly and report partial success. Deliverable: a working deploy.sh tested against localhost or a real server.

Hard