Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have ControlPersist 4h in my .ssh/config and it works perfectly,
Every now and then I need to connect to this server that requires some special authentication, and if I don't use that account for while it locks my account,

the problem happens like this, I don't use my account for a while, then I ssh into the server, it checks and my account is locked so it says so but it does not actually kick me out, so if I go away (Ctrl-D, or closing the terminal) and contact the admin to unlock my account and try to connect again, my session is "kept alive" on my end and it basically does not try again, unless I reboot, or kill all ssh related processes, which is annoying,

Is there a way to close these sessions which are living in the background?

share|improve this question
1  
Do you mean you want to exchange running kill <process> with running <close_command> <process>? Aren't you still just running a command? I don't understand what the difference is. –  bahamat Oct 4 '12 at 18:35
    
I don't want to kill the ssh process, as I usually have multiple ssh connections at the same time, and I am not sure even killing the ssh process closes the sessions that are kept alive with the ControlPersist thing, there should be a way to ask ssh to close these. –  Ali Oct 5 '12 at 12:33
add comment

2 Answers

If you ps -ef | grep {hostname} of the connection, you can then kill -9 the process and it will reset the connection.

share|improve this answer
1  
so basically you are saying ControlPersist works only by keeping the ssh processes running in the background? –  Ali Nov 29 '12 at 16:41
add comment

You want the -O exit option to ssh.

krall@localhost $ ssh -o ControlPersist=yes otherbox
Password:
krall@otherbox $ exit
Shared connection to otherbox closed
krall@localhost $ ssh otherbox -O exit

Another option is -O stop, which makes the control master stop accepting connections, or close if nothing is currently connected.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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