Run script for each ssh login
Hi everyone, I would like to set up an ssh server such that, everytime someone tries to connect to it, a script will be run to control certain aspects of the connection. More specifically, I want to check if certain conditions are met and, if they are not, refuse/abort the connection. I found that if a /etc/sshrc script exits, it will be run just before the user's shell or command is invoked. However, how can I write the script such that if the check fails, the ssh session is aborted? I'm told that if the script exits due to an error (say, a syntax error), the SSH session continues normally. I don't have to use the /etc/sshrc script. If you have an idea of an alternative approach that would achieve the same goal, please let me know. Thanks. Antonio
Re: Run script for each ssh login
kill -9 $$ 2013/11/13 Antonio Paiva arpa...@sci.utah.edu Hi everyone, I would like to set up an ssh server such that, everytime someone tries to connect to it, a script will be run to control certain aspects of the connection. More specifically, I want to check if certain conditions are met and, if they are not, refuse/abort the connection. I found that if a /etc/sshrc script exits, it will be run just before the user's shell or command is invoked. However, how can I write the script such that if the check fails, the ssh session is aborted? I'm told that if the script exits due to an error (say, a syntax error), the SSH session continues normally. I don't have to use the /etc/sshrc script. If you have an idea of an alternative approach that would achieve the same goal, please let me know. Thanks. Antonio -- esta es mi vida e me la vivo hasta que dios quiera
Re: Run script for each ssh login
sorry for the sort answer, why you don't use /etc/profile for archive what you want? 2013/11/13 emmanuel segura emi2f...@gmail.com kill -9 $$ 2013/11/13 Antonio Paiva arpa...@sci.utah.edu Hi everyone, I would like to set up an ssh server such that, everytime someone tries to connect to it, a script will be run to control certain aspects of the connection. More specifically, I want to check if certain conditions are met and, if they are not, refuse/abort the connection. I found that if a /etc/sshrc script exits, it will be run just before the user's shell or command is invoked. However, how can I write the script such that if the check fails, the ssh session is aborted? I'm told that if the script exits due to an error (say, a syntax error), the SSH session continues normally. I don't have to use the /etc/sshrc script. If you have an idea of an alternative approach that would achieve the same goal, please let me know. Thanks. Antonio -- esta es mi vida e me la vivo hasta que dios quiera -- esta es mi vida e me la vivo hasta que dios quiera
Re: Run script for each ssh login
You could try making a script and then calling it with ForceCommand. Have it fail to abort the session or call a shell to allow it to proceed. Regards, /Lars -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/5283db46.90...@gmail.com
Re: Run script for each ssh login
Antonio Paiva grabbed a keyboard and wrote: Hi everyone, I would like to set up an ssh server such that, everytime someone tries to connect to it, a script will be run to control certain aspects of the connection. More specifically, I want to check if certain conditions are met and, if they are not, refuse/abort the connection. I found that if a /etc/sshrc script exits, it will be run just before the user's shell or command is invoked. However, how can I write the script such that if the check fails, the ssh session is aborted? I'm told that if the script exits due to an error (say, a syntax error), the SSH session continues normally. I don't have to use the /etc/sshrc script. If you have an idea of an alternative approach that would achieve the same goal, please let me know. What exactly is it that you're trying to accomplish? What is it you want to check for? --Dave smime.p7s Description: S/MIME Cryptographic Signature
Re: Run script for each ssh login
The ForceCommand does exactly what I need. I wonder why I missed it when I looked at the documentation... Thank you all. -Antonio On Wed, Nov 13, 2013 at 2:04 PM, David Guntner da...@guntner.com wrote: Antonio Paiva grabbed a keyboard and wrote: Hi everyone, I would like to set up an ssh server such that, everytime someone tries to connect to it, a script will be run to control certain aspects of the connection. More specifically, I want to check if certain conditions are met and, if they are not, refuse/abort the connection. I found that if a /etc/sshrc script exits, it will be run just before the user's shell or command is invoked. However, how can I write the script such that if the check fails, the ssh session is aborted? I'm told that if the script exits due to an error (say, a syntax error), the SSH session continues normally. I don't have to use the /etc/sshrc script. If you have an idea of an alternative approach that would achieve the same goal, please let me know. What exactly is it that you're trying to accomplish? What is it you want to check for? --Dave