0
I'm trying to run a script/shell just after I login via ssh to my host with a "guestUser" the mission of this user is to connect to another remote host via ssh, I've created this user on my host:
guestUser:x:1234:1234::/home/guest:/bin/bash
Then, in guest directory I have a .bashrc
file where I add this, following this answer (Linux: How to automatically run commands on SSH login?):
if[[ -n $SSH_CONNECTION ]] ; then
ssh 192.198.1.99
fi
I did this because I need in this step "guestUser" introduces sshUserInRemoteTwo and sshUserPasswordInRemoteTwo. It does not work. The script tries to log "guestUser" in the remoteHostTwo
as "guestUser", that's not the goal, I need the script asks for user/password.
If I get it works: script asks for user/password and login correctly on the second host, then, once SHH connection with the second host is over, guestUser being offline my host; because at the moment, SSH connection is over and user keeps on my host.
ok, and what about once this connection is over, what can i do to logout guestUSer from the first host too? – Di36o – 2015-04-01T18:27:54.753
By default, all SSH servers have a connection timeout. SSH only maintains a connection as long as keep alive packets are continually sent. My suggestion is to simply close the terminal window to close both connections within a few minutes. If you are in single user mode then just type
exit
, pressenter
, and typeexit
once more. – krowe – 2015-04-02T00:01:15.373I did it, I type
exit
but that's not the goal, because I need a callback or something similar. A script to logout from the firstHost.I give acces to first host just because this one is the only secure/allowed host to connect to the second, once the SSH session on the second Host, i need logout inmediatly from the first too.
Searching in google, i found i "could" use a demon to listen to the SSH session, once it is over, demon run the logout script, but i don't know how to implement that. – Di36o – 2015-04-02T17:45:59.730