Bash & Linux·Bash from first command to automation

SSH and remote machines

Connect securely, copy files and use keys instead of passwords.

Beginner 13 min read Lesson 9 of 300 Challenge included
What you will be able to do
  • Use ssh user@host to connect.
  • Generate keys with ssh-keygen -t ed25519.
  • Copy a public key with ssh-copy-id.
  • Use rsync for repeatable file sync.

In plain English

SSH encrypts a remote shell session. Use key authentication, keep the private key local and never paste it into a chat or a repository. scp and rsync copy files over the same secure channel.

terminalTerminal
ssh-keygen -t ed25519 -C "you@example.com"
ssh-copy-id deploy@example.com
ssh deploy@example.com 'uname -a'
rsync -avz ./dist/ deploy@example.com:/var/www/app/
Your turn

Copy a project

Medium

Write an rsync command that copies ./dist/ to /var/www/app/ on deploy@example.com.

BASH · starter
rsync
Check your understanding before moving on.
Knowledge checkQuestion 1

Which file is copied to a server for key authentication?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Automation project
Lesson 9 of 300 · 0% of course