Find out which process steadily creates new outgoing ssh connections











up vote
0
down vote

favorite












I'm trying to figure out which process is flooding the system with outgoing ssh connections. I know that netstat can be used for this, but it doesn't show me the pid of such a connection. Also, the connections are all in the TIME_WAIT state. Executing the command



root@debian:~# netstat -taupent | grep "Inode|192.168.0.9:(4|5).*"



displays the following output



Proto Recv-Q Send-Q Local Address           Foreign Address         State       Benutzer   Inode      PID/Program name
tcp 0 0 192.168.0.9:57592 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57590 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57588 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57594 192.168.0.2:22 TIME_WAIT 0 0 -


After a minute the same command gives me new connections with different ports. These ports are also not listed in the lsof -i :<port> output.
I've added a rule in iptables -A OUTPUT -p tcp -m tcp --dport 22 -j LOG --log-prefix "ssh connection" in the hope to get some more information, but I'm not seeing anything in the log output that helps me to solve my problem. Here is a sample log entry:



 [1944832.763717] ssh connectionIN= OUT=enp0s3 SRC=192.168.0.9 DST=192.168.0.2 LEN=52 TOS=0x08 PREC=0x00 TTL=64 ID=54394 DF PROTO=TCP SPT=59532 DPT=22 WINDOW=431 RES=0x00 ACK URGP=0


Any help appreciated!



System Info:



Icon name: computer-vm
Chassis: vm
Virtualization: oracle
Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 4.9.0-8-amd64
Architecture: x86-64









share|improve this question


















  • 2




    TIME_WAIT is explained here. You may try this approach applied to ssh (instead of rm).
    – Kamil Maciorowski
    Dec 3 at 11:38










  • @KamilMaciorowski It worked,thank you very much! And btw, really nice trick!
    – dejard
    Dec 4 at 7:00















up vote
0
down vote

favorite












I'm trying to figure out which process is flooding the system with outgoing ssh connections. I know that netstat can be used for this, but it doesn't show me the pid of such a connection. Also, the connections are all in the TIME_WAIT state. Executing the command



root@debian:~# netstat -taupent | grep "Inode|192.168.0.9:(4|5).*"



displays the following output



Proto Recv-Q Send-Q Local Address           Foreign Address         State       Benutzer   Inode      PID/Program name
tcp 0 0 192.168.0.9:57592 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57590 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57588 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57594 192.168.0.2:22 TIME_WAIT 0 0 -


After a minute the same command gives me new connections with different ports. These ports are also not listed in the lsof -i :<port> output.
I've added a rule in iptables -A OUTPUT -p tcp -m tcp --dport 22 -j LOG --log-prefix "ssh connection" in the hope to get some more information, but I'm not seeing anything in the log output that helps me to solve my problem. Here is a sample log entry:



 [1944832.763717] ssh connectionIN= OUT=enp0s3 SRC=192.168.0.9 DST=192.168.0.2 LEN=52 TOS=0x08 PREC=0x00 TTL=64 ID=54394 DF PROTO=TCP SPT=59532 DPT=22 WINDOW=431 RES=0x00 ACK URGP=0


Any help appreciated!



System Info:



Icon name: computer-vm
Chassis: vm
Virtualization: oracle
Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 4.9.0-8-amd64
Architecture: x86-64









share|improve this question


















  • 2




    TIME_WAIT is explained here. You may try this approach applied to ssh (instead of rm).
    – Kamil Maciorowski
    Dec 3 at 11:38










  • @KamilMaciorowski It worked,thank you very much! And btw, really nice trick!
    – dejard
    Dec 4 at 7:00













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to figure out which process is flooding the system with outgoing ssh connections. I know that netstat can be used for this, but it doesn't show me the pid of such a connection. Also, the connections are all in the TIME_WAIT state. Executing the command



root@debian:~# netstat -taupent | grep "Inode|192.168.0.9:(4|5).*"



displays the following output



Proto Recv-Q Send-Q Local Address           Foreign Address         State       Benutzer   Inode      PID/Program name
tcp 0 0 192.168.0.9:57592 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57590 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57588 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57594 192.168.0.2:22 TIME_WAIT 0 0 -


After a minute the same command gives me new connections with different ports. These ports are also not listed in the lsof -i :<port> output.
I've added a rule in iptables -A OUTPUT -p tcp -m tcp --dport 22 -j LOG --log-prefix "ssh connection" in the hope to get some more information, but I'm not seeing anything in the log output that helps me to solve my problem. Here is a sample log entry:



 [1944832.763717] ssh connectionIN= OUT=enp0s3 SRC=192.168.0.9 DST=192.168.0.2 LEN=52 TOS=0x08 PREC=0x00 TTL=64 ID=54394 DF PROTO=TCP SPT=59532 DPT=22 WINDOW=431 RES=0x00 ACK URGP=0


Any help appreciated!



System Info:



Icon name: computer-vm
Chassis: vm
Virtualization: oracle
Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 4.9.0-8-amd64
Architecture: x86-64









share|improve this question













I'm trying to figure out which process is flooding the system with outgoing ssh connections. I know that netstat can be used for this, but it doesn't show me the pid of such a connection. Also, the connections are all in the TIME_WAIT state. Executing the command



root@debian:~# netstat -taupent | grep "Inode|192.168.0.9:(4|5).*"



displays the following output



Proto Recv-Q Send-Q Local Address           Foreign Address         State       Benutzer   Inode      PID/Program name
tcp 0 0 192.168.0.9:57592 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57590 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57588 192.168.0.2:22 TIME_WAIT 0 0 -
tcp 0 0 192.168.0.9:57594 192.168.0.2:22 TIME_WAIT 0 0 -


After a minute the same command gives me new connections with different ports. These ports are also not listed in the lsof -i :<port> output.
I've added a rule in iptables -A OUTPUT -p tcp -m tcp --dport 22 -j LOG --log-prefix "ssh connection" in the hope to get some more information, but I'm not seeing anything in the log output that helps me to solve my problem. Here is a sample log entry:



 [1944832.763717] ssh connectionIN= OUT=enp0s3 SRC=192.168.0.9 DST=192.168.0.2 LEN=52 TOS=0x08 PREC=0x00 TTL=64 ID=54394 DF PROTO=TCP SPT=59532 DPT=22 WINDOW=431 RES=0x00 ACK URGP=0


Any help appreciated!



System Info:



Icon name: computer-vm
Chassis: vm
Virtualization: oracle
Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 4.9.0-8-amd64
Architecture: x86-64






linux ssh netstat






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 3 at 10:42









dejard

1




1








  • 2




    TIME_WAIT is explained here. You may try this approach applied to ssh (instead of rm).
    – Kamil Maciorowski
    Dec 3 at 11:38










  • @KamilMaciorowski It worked,thank you very much! And btw, really nice trick!
    – dejard
    Dec 4 at 7:00














  • 2




    TIME_WAIT is explained here. You may try this approach applied to ssh (instead of rm).
    – Kamil Maciorowski
    Dec 3 at 11:38










  • @KamilMaciorowski It worked,thank you very much! And btw, really nice trick!
    – dejard
    Dec 4 at 7:00








2




2




TIME_WAIT is explained here. You may try this approach applied to ssh (instead of rm).
– Kamil Maciorowski
Dec 3 at 11:38




TIME_WAIT is explained here. You may try this approach applied to ssh (instead of rm).
– Kamil Maciorowski
Dec 3 at 11:38












@KamilMaciorowski It worked,thank you very much! And btw, really nice trick!
– dejard
Dec 4 at 7:00




@KamilMaciorowski It worked,thank you very much! And btw, really nice trick!
– dejard
Dec 4 at 7:00















active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1380368%2ffind-out-which-process-steadily-creates-new-outgoing-ssh-connections%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1380368%2ffind-out-which-process-steadily-creates-new-outgoing-ssh-connections%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mouse cursor on multiple screens with different PPI

Agildo Ribeiro

Sometime when accessing a menu: “Ubuntu 16.04 has experienced an internal error”