I have a SFTP server, where clients connect every minute to exchange files. There are few clients who connect and then dont disconnect resulting in a lot of connections over a period of time. This is choking up the CPU. I have set ClientAliveInterval and ClientAliveCountMax in sshd_config which disconnects idle ssh connection after a certain period, but id doesnt seem to disconnect the idle sftp connections. How do I force idle sftp connections to disconnect?
Ssh – How to disconnect idle SFTP users
sftpssh
Related Topic
- Ssh – How to automate SSH login with password
- Ubuntu – Setting up simple sandboxed sftp for one user
- Ssh – Debugging flaky SSH tunnel
- Ssh – File/Directory permissions for SFTP user
- ssh – Difference Between OpenSSH internal-sftp and sftp-server
- Ubuntu – A simple, step-by-step way of setting up of “jailed” SFTP-only accounts
Best Answer
Try this step by step:
pstree -p
-- the whole process tree will be displayed.w
- Who is doing what. - may be this will not be necessary (or maybe you can get the idle times for the users.)ps aux| grep sshd
Try to get the process id of sshd session, which is the parent process of the sftp server. You can get a user's sftp process id from
ps aux | grep sshd
, the kill its parent process:ps output will be like:
pstree -p output will be like:
And you're going to do
kill 24034
, because it is parent sshd session for the process user "metin" have been using as process 24042 (take a look atps
output above).And also you can get their status (Idle, sleep, active and etc.) from the output of the
ps
.If you want to do this automatically, I don't know any software for this, but you can write your own script.