Skip to content
Learn Netverks

Lesson

Step 26/36 72% through track

ssh-bash

SSH from Bash

Last reviewed May 28, 2026 Content v20260528
Track mode
none
Means
Read / quiz
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches SSH from Bash: the syntax, patterns, and safety habits you need before advancing in Bash.

Teams still ship SSH from Bash in Bash codebases—skipping it leaves gaps in debugging and code reviews.

You will apply SSH from Bash in contexts like: Remote server maintenance, pre-commit checks, and deploy hooks.

Read each lesson, copy bash examples into your own terminal, and complete the lesson MCQs—there is no in-browser runner for security reasons.

When you can explain the previous lesson's ideas without copying starter code.

SSH runs remote shells and copies files. Bash scripts often wrap ssh and scp for deploys—prefer keys over passwords.

Remote command

ssh user@host "hostname && uptime"
ssh -i ~/.ssh/id_ed25519 deploy@prod "sudo systemctl status nginx"

Quote remote commands so local shell does not parse them first.

Copy files

scp local.txt user@host:/tmp/
scp -r ./dist user@host:/var/www/app/

-r recurses for directories—verify destination paths to avoid overwriting wrong trees.

Config file

~/.ssh/config can define Host aliases, IdentityFile, and ProxyJump—reduces typing and documents team conventions. Never share private keys; use Tools docs for key generation.

Important interview questions and answers

  1. Q: Why quote remote commands?
    A: Local shell would otherwise split on spaces and expand globs.
  2. Q: scp vs rsync?
    A: scp is simple; rsync adds delta sync—both common in Bash deploy scripts.

Self-check

  1. What flag selects an identity file for ssh?
  2. What scp flag copies directories recursively?

Tip: Use SSH keys with passphrase + agent—document in Tools.

Interview prep

Quote remote command?

Prevent local shell from parsing remote words.

scp -r?

Recursive copy for directories.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • StrictHostKeyChecking?
  • ssh-agent keys?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump