New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can´t bind to port 22 #12

Closed
TheHades opened this Issue Jun 29, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@TheHades
Copy link

TheHades commented Jun 29, 2015

Starting cowrie in the background...
An error has occurred: 'Couldn't listen on 0.0.0.0:22: [Errno 13] Permission denied.'
Please look at log file for more information.

Any solution for binding cowrie at port 22? (SSH is running NOT running at Port 22)

@MikeDawg

This comment has been minimized.

Copy link
Contributor

MikeDawg commented Jun 29, 2015

I believe this is an OS level implementation problem. Using ports <1024 require root level privileges. To that point, I hope that you're not running cowrie as a root user.

I would highly recommend running this service as a non-privileged account, and that you use iptables port redirection in order to get the system to appear to have this service running on port 22.

@TheHades

This comment has been minimized.

Copy link

TheHades commented Jun 29, 2015

Hm you are right.

No, i didn´t run cowrie as root user.. I´m not insane. 😄

That should do the trick.
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 2222 -j REDIRECT --to-port 22

@micheloosterhof

This comment has been minimized.

Copy link
Member

micheloosterhof commented Jun 29, 2015

MikeDawg is correct. You are probably not root and ports < 1024 require root priviledes.
Don't run it as root. Two ways to get around this:

  1. Run 'iptables' to redirect port 22 incoming to port 2222.
  2. On Linux, you can give the cowrie binary capabilities to listen only on 22 only without additional root rights, run: "setcap cap_net_bind_service=+ep /usr/bin/python."

regards,
Michel.

@micheloosterhof

This comment has been minimized.

Copy link
Member

micheloosterhof commented Jun 29, 2015

Seems to be solved, I'll close the ticket!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment