Chapter 2 · Lesson 10
Advanced
1 min read
SSH and Remote Shell Access
Overview
SSH provides encrypted remote command execution and file transfer. It uses the server's host key for identity, an authentication method such as a key or password and Unix process permissions after login.
Detailed Notes
Connect
bash
ssh learner@server.example.com
ssh -i ~/.ssh/production.pem ubuntu@10.0.0.12
ssh -p 2222 learner@server.example.com
-iselects a private key.-pchanges the SSH port.- The key is private; it must not be shared or committed.
Generate an SSH key
bash
ssh-keygen -t ed25519 -C "work laptop"
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
Copy the public key to a server:
bash
ssh-copy-id learner@server.example.com
The server records it in ~/.ssh/authorized_keys.
File transfer
bash
scp local.txt learner@server:/tmp/local.txt
scp -r build/ learner@server:/opt/app/
sftp learner@server
Preserve the target path and review ownership after copying.
SSH config
ssh-config
Host production
HostName 10.0.0.12
User ubuntu
IdentityFile ~/.ssh/production
Port 22
Then:
bash
ssh production
Place this in ~/.ssh/config and set its permissions with chmod 600 ~/.ssh/config.
Never disable host key checking in normal use; it removes protection against a changed or intercepted server identity.
Common Interview Questions
Finished this lesson?
0 of 25 lessons done · 0% of the course

