-1

On a Linux cloud machine, I want to set up a learning station for beginners (pubnix/pubunix).

How can I block all internet except for incoming SSH (ssh user@cloudmachine) and except for SSH local port fowarding (ssh -L 8080:localhost:8080 user@cloudmachine, including scp/rsync) for non-root users?

sudo users (me) on the cloud machine should have full access (sudo apt-get install someprogram).

Regular users (my friends) should only be able to use the programs I have pre-installed for them (jq info.json, but curl https://example.com should fail/time out because of no internet, and curl localhost should still work because it doesn't leave the network).

They will send me their public SSH keys and I will set up their home directories.

This is what I have so far:

# allow incoming SSH sessions (ssh user@cloudmachine)
iptables -A INPUT -p tcp --dport ssh -j ACCEPT

# allow local port forwarding (ssh -L 8080:localhost:8080 user@cloudmachine)
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

# allow required ICMP packets
iptables -A INPUT -p icmp -j ACCEPT

# allow all packets for root
iptables -A OUTPUT -m owner --uid-owner root -j ACCEPT

# drop all other packets
iptables -P INPUT DROP

Is this enough to set it up as described above?

3
  • Those rules by themselves should not lock you out. I can set them up on my own server and still ssh into it without a problem.
    – larsks
    Commented Jun 24 at 0:03
  • ssh -L 8080:localhost:8080 user@cloudmachine looks like a very peculiar way to provide authentication for a web resource.
    – symcbean
    Commented Jun 24 at 9:55
  • @symcbean the intention is to allow users to be able to use the machine as similar as possible as a regular one (including being able to start their own web servers for personal use/development), while not being able to access the public internet from within the machine. I'm happy to hear alternative solutions to achieve this safely.
    – wjwrpoyob
    Commented Jun 24 at 16:23

0

You must log in to answer this question.

Browse other questions tagged .