0
0
Linux CLIscripting~20 mins

SSH tunneling (port forwarding) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SSH Tunnel Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the effect of this SSH command?
You run this command on your local machine:
ssh -L 8080:internal.server.com:80 user@remotehost

What does this command do?
AIt forwards local port 8080 to port 80 on internal.server.com through remotehost.
BIt forwards remotehost's port 8080 to your local port 80.
CIt creates a reverse tunnel from internal.server.com port 80 to your local port 8080.
DIt forwards remotehost's port 80 to internal.server.com port 8080.
Attempts:
2 left
💡 Hint
Remember that -L means local port forwarding from your machine.
💻 Command Output
intermediate
2:00remaining
What output does this SSH reverse tunnel command produce?
You run this command:
ssh -R 9090:localhost:3000 user@remotehost

What does this command do?
AIt forwards your local port 3000 to remotehost's port 9090.
BIt forwards your local port 9090 to remotehost's port 3000.
CIt forwards remotehost's port 3000 to your local port 9090.
DIt forwards remotehost's port 9090 to your local machine's port 3000.
Attempts:
2 left
💡 Hint
The -R option creates a reverse tunnel from remotehost to your local machine.
🔧 Debug
advanced
2:00remaining
Why does this SSH tunnel command fail with 'bind: Address already in use'?
You run:
ssh -L 8080:localhost:80 user@remotehost

But get the error:
bind: Address already in use

What is the most likely cause?
AYour SSH user does not have permission to connect to remotehost.
BRemotehost's port 80 is blocked by firewall.
CLocal port 8080 is already used by another process on your machine.
DYou typed the command with wrong syntax.
Attempts:
2 left
💡 Hint
The error mentions 'bind' which relates to local port usage.
🧠 Conceptual
advanced
2:00remaining
Which SSH option allows dynamic port forwarding?
You want to create a SOCKS proxy using SSH. Which option should you use?
A-D
B-L
C-R
D-X
Attempts:
2 left
💡 Hint
Dynamic forwarding creates a proxy that can handle many ports dynamically.
🚀 Application
expert
3:00remaining
How to securely access a web server behind a firewall using SSH tunneling?
You have a web server running on port 80 inside a private network. You can SSH into a gateway server in that network but cannot access the web server directly. Which SSH command lets you access the web server from your local browser at http://localhost:8080?
Assh -D 8080 user@gateway
Bssh -L 8080:webserver.internal:80 user@gateway
Cssh -R 8080:webserver.internal:80 user@gateway
Dssh -L 80:localhost:8080 user@gateway
Attempts:
2 left
💡 Hint
You want to forward a local port to the internal web server through the gateway.