Unit 4: Users and groups · Lesson 6 of 7 · 16 min
SSH agent forwarding
Forwarding lends your keys to every server you visit. Find where it is on and replace it with a jump host.
mission
- You are
- You are reviewing how developers reach web01.
- Situation
- riya's SSH config forwards her agent everywhere. While she is connected, root on that server can use her keys to reach anything else her keys open.
- Goal
- See which hosts get her agent and what web01 itself allows.
- Hand in
- A config change for developers and one for the server.
What forwarding lends
- LaptopThe agent holds riya's key
- web01Root here can talk to her agent through the socket
- db01Reached with her key, without her knowing
Resolve the config for one host
ssh -G prints the final settings for a host without connecting.
ssh -G -F home/riya/.ssh/config web01 | grep -E '^(hostname|user|forwardagent) '
user riya
hostname 10.20.0.11
forwardagent yes
you should see forwardagent yes for web01.
And for any other host
ssh -G -F home/riya/.ssh/config db01 | grep -E '^forwardagent '
forwardagent yes
you should see Also yes, because the rule is under Host *.
Check the server side
grep -Ei '^(AllowAgentForwarding|AllowTcpForwarding)' /etc/ssh/sshd_config /srv/baseline/sshd_config.hardened
/etc/ssh/sshd_config:AllowTcpForwarding yes
/srv/baseline/sshd_config.hardened:AllowTcpForwarding no
you should see web01 allows TCP forwarding today. The hardened baseline turns it off.
Reaching db01 through web01
Host *
ForwardAgent yes
ssh web01, then ssh db01Keys usable by anyone with root on web01
Host db01
ProxyJump web01
ssh db01Encrypted end to end, keys never leave the laptop
What a defender takes away
- 1ForwardAgent yes under Host * is a finding.
- 2ProxyJump reaches inner hosts without lending keys.
- 3ssh -G shows the settings that will really apply.
Questions
0 of 2 solved
Answer each one from what you find on your lab machine.