📝 Update Phase 1 & 2 with Alpine-specific fixes (ash vs bash, rsync install, SSH key details)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 🌐 Phase 2: Networking
|
||||
|
||||
> Goal: Machines communicate — ping, SSH, file transfers
|
||||
> Goal: Machines communicate — ping, SSH, file transfers, services
|
||||
|
||||
---
|
||||
|
||||
@@ -18,50 +18,76 @@ ping -c 4 10.0.1.1 # From alpine-2 → alpine-1
|
||||
# Check ARP table
|
||||
ip neigh
|
||||
|
||||
# Advanced network tools
|
||||
ip addr # All interfaces
|
||||
ip route # Routing table
|
||||
traceroute 10.0.1.2 # Path between VMs
|
||||
# tcpdump (packet capture) — Alpine needs install first
|
||||
apk add tcpdump
|
||||
tcpdump -i eth0 -c 5 icmp &
|
||||
ping -c 3 10.0.1.2
|
||||
```
|
||||
|
||||
### 📝 Questions:
|
||||
1. What's the MAC address of the other VM?
|
||||
2. Can you ping alpine-hop (10.0.1.3) from alpine-1?
|
||||
3. What subnet are you on? How many usable hosts?
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Exercise 2 — SSH Keys
|
||||
|
||||
```bash
|
||||
# Generate an SSH key
|
||||
# Step 1 — Generate an SSH key pair
|
||||
ssh-keygen -t ed25519
|
||||
# Press Enter for all prompts (no passphrase)
|
||||
|
||||
# Copy to the other VM
|
||||
# Step 2 — What just got created?
|
||||
ls -la ~/.ssh/
|
||||
# id_ed25519 ← your PRIVATE key (NEVER share this!)
|
||||
# id_ed25519.pub ← your PUBLIC key (safe to share)
|
||||
|
||||
# Step 3 — Copy your public key to alpine-2
|
||||
ssh-copy-id root@10.0.1.2
|
||||
# Enter root password for alpine-2 when prompted
|
||||
|
||||
# Test passwordless login
|
||||
# Step 4 — Test passwordless login!
|
||||
ssh root@10.0.1.2 'hostname; uptime'
|
||||
# Should work WITHOUT asking for a password 🎉
|
||||
|
||||
# Step 5 — See what ssh-copy-id did
|
||||
ssh root@10.0.1.2 'cat ~/.ssh/authorized_keys'
|
||||
```
|
||||
|
||||
### 💡 How it works
|
||||
Your public key is appended to `~/.ssh/authorized_keys` on the target. When you SSH, the server checks if you have the matching **private key** — no password needed! 🔑
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Exercise 3 — File Transfer
|
||||
## 🎯 Exercise 3 — File Transfer (SCP & RSYNC)
|
||||
|
||||
```bash
|
||||
# SCP (secure copy)
|
||||
echo "Secret message" > /root/secret.txt
|
||||
scp /root/secret.txt root@10.0.1.2:/root/
|
||||
# SCP — single files
|
||||
echo "CCNA study notes" > /root/study.txt
|
||||
scp /root/study.txt root@10.0.1.2:/root/
|
||||
|
||||
# RSYNC (sync directories)
|
||||
# Verify
|
||||
ssh root@10.0.1.2 'cat /root/study.txt'
|
||||
|
||||
# RSYNC — directories (need to install on Alpine)
|
||||
apk add rsync
|
||||
rsync -av /root/lab/ root@10.0.1.2:/root/lab-backup/
|
||||
|
||||
# Verify the backup
|
||||
ssh root@10.0.1.2 'ls -la /root/lab-backup/'
|
||||
```
|
||||
|
||||
### 📝 Questions:
|
||||
1. What's the difference between `scp` and `rsync`?
|
||||
2. What does the `-a` flag in `rsync -av` mean? (hint: check `man rsync`)
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Exercise 4 — Network Services
|
||||
|
||||
```bash
|
||||
# Check listening ports
|
||||
# Check what's listening on your VM
|
||||
ss -tlnp
|
||||
|
||||
# Start a simple HTTP server on alpine-1
|
||||
@@ -70,16 +96,33 @@ python3 -m http.server 8080 &
|
||||
# Access it from alpine-2
|
||||
curl http://10.0.1.1:8080/
|
||||
|
||||
# Kill the server
|
||||
# See the connection in your server logs
|
||||
# Kill the server when done
|
||||
kill %1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Bonus: CCNA Challenge
|
||||
|
||||
```bash
|
||||
# From alpine-1, can you SSH to alpine-hop?
|
||||
ssh root@10.0.1.3
|
||||
|
||||
# Check the routing table
|
||||
ip route
|
||||
|
||||
# Why can alpine-1 reach alpine-hop (10.0.1.3)?
|
||||
# Why can't alpine-1 reach the internet?
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ Phase 2 Checklist
|
||||
- [ ] Ping between VMs
|
||||
- [ ] SSH key-based auth
|
||||
|
||||
- [ ] Ping and ARP (`ip neigh`)
|
||||
- [ ] SSH key generation and passwordless login
|
||||
- [ ] File transfer with `scp` / `rsync`
|
||||
- [ ] Network services
|
||||
- [ ] Running a network service
|
||||
|
||||
**Previous:** [[Phase 1 - Walking]] | **Next:** [[Phase 3 - Users and Files]]
|
||||
|
||||
Reference in New Issue
Block a user