简体   繁体   English

使用Linux PID查找IP地址

[英]Finding IP address using Linux PID

  1. How to get IP address by using Pid in Linux. 如何在Linux中使用Pid获取IP地址。 and what that pId doing. 以及那个pId在做什么。 Is there any way? 有什么办法吗?

  2. Only allow the particular user only from that particular IP address, if that user use apart from other IP address must to block. 如果该用户必须与其他IP地址分开使用,则仅允许该特定IP地址中的特定用户使用。 Only that user allow from that IP address. 只有该用户允许使用该IP地址。 Is this Possible? 这可能吗?

It seem your question is bad written. 您的问题似乎写得不好。 If i understand what you are looking for: 如果我了解您在寻找什么:

1/ About PID 1 /关于PID

A PID is a process id. PID是一个进程ID。 A process is linked to an user. 流程链接到用户。 An user can to be a local user or remote ( with ssh by example ) . 用户可以是本地用户或远程用户(例如ssh)。

Into a shell if you put 如果放入外壳

$ ps u --pid 2525

Where 2525 is a pid, this command will tell to you which user is linked to this process 如果2525是pid,此命令将告诉您哪个用户链接到该进程

$ \w

That will display a list of user currently connected ( local and remotely ) with their corresponding external IP 这将显示当前已连接用户(本地和远程)及其相应外部IP的列表。

Alternatively to \\w you can use 除了\\ w之外,您还可以使用

$ who user3563068

This command is close to \\w and filter to given username 该命令靠近\\ w并过滤为给定的用户名

2/ How to restrict remote access to your computer ? 2 /如何限制对计算机的远程访问?

Using fail2ban will block any external ip which fail to login. 使用fail2ban将阻止任何无法登录的外部IP。 fail2ban is to me the way you should to take. 在我看来,fail2ban是您应该采取的方式。

Miscellaneous

To see successful login: 要查看成功登录:

$ last

To see unsuccessful login: 要查看登录失败:

$ lastb

Allowing access from only one IP: 仅允许从一个IP访问:

$ iptables -A INPUT -s 192.168.0.2 -j ACCEPT

Where 192.168.0.2 is your ip 192.168.0.2是您的IP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM