Ravindra BagaleCourses & study guides

Chapter 4: Linux Ops Refresh for DevOps

4.6 SSH keys, scp, rsync — one-liners

You already use SSH from the AWS course. Refresh only what DevOps scripts and CI need later.

SSH keys (idea). A key pair lets you log in without typing a password each time. Private key stays on your laptop (never in Git). Public key sits on the server in authorized_keys.

# connect (example — use your key path and host)
ssh -i ~/.ssh/your-lab-key.pem ec2-user@<PUBLIC_IP>

# copy a file to the server
scp -i ~/.ssh/your-lab-key.pem ./README.md ec2-user@<PUBLIC_IP>:~/

# sync a folder (dry-run first with -n if you want)
rsync -avz -e "ssh -i ~/.ssh/your-lab-key.pem" ./app/ ec2-user@<PUBLIC_IP>:~/app/

Why rsync. It copies only changes. Handy before you automate deploys with Ansible or a pipeline SSH step.

Keep private May be public / on server
.pem / private key files Public key in authorized_keys
Production passwords Deploy scripts without embedded secrets

Keys and Git

Never commit .pem or private keys. Chapter 2 .gitignore already lists *.pem — keep it that way.

Ravindra Bagale's Tip

Khup students scp server varun chalavtat aani path gondhaltat. scp/rsync usually laptop varun remote path saha. Direction lakshat theva!

Practice task

Write the exact scp command shape to upload healthcheck.sh from your laptop to ec2-user@IP:~/bin/. Do not invent a real IP — use a placeholder.