If remote access session is enabled, I have to disable and later enable it. How to achieve this using Python code?.


I'm not completely sure what you mean by a remote access session.

To see all listening services / ports run one of the following commands:

sudo lsof -i -P -n | grep LISTEN
sudo netstat -tulpn | grep LISTEN

If you leave off the | grep LILSTEN part the same commands will also show active connections.

sudo lsof -i -P -n
sudo netstat -tulpn

Typically VNC connections will use ports of 5900 or so.

On my system I see:

systemd      1    root   33u  IPv4  17131      0t0  TCP *:111 (LISTEN)
systemd      1    root   41u  IPv6  17133      0t0  TCP *:111 (LISTEN)
cupsd     2071    root    6u  IPv6  43261      0t0  TCP [::1]:631 (LISTEN)
cupsd     2071    root    7u  IPv4  43262      0t0  TCP (LISTEN)

So I know everything on that list.

I suppose it is possible for crackers to hide services, but that is a separate discussion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.