How to close/kill SSH connection when bash shell exits?What steps does the system go through when handling an...
Why wasn't ASCII designed with a contiguous alphanumeric character order?
My colleague is constantly blaming me for his errors
How could a satellite follow earth around the sun while staying outside of earth's orbit?
Does a Hand Crossbow with the Repeating Shot Infusion still require a Free Hand to use?
Put my student loan in parents’ second mortgage - help?
Story where diplomats use codes for emotions
I hit a pipe with a mower and now it won't turn
I need help with pasta
Reusable spacecraft: why still have fairings detach, instead of open/close?
Could this problem be tackled using Mathematica?
Find the radius of the hoop.
Are the requirements of a Horn of Valhalla cumulative?
Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?
Who voices the character "Finger" in The Fifth Element?
Movie with Zoltar in a trailer park named Paradise and a boy playing a video game then being recruited by aliens to fight in space
Word ending in "-ine" for rat-like
Why wasn't EBCDIC designed with contiguous alphanumeric characters?
for xml path('') output
How receiver knows the exact frequency in the channel to "listen to"?
13th chords on guitar
Present Perfect with "one of these days"
Thin wall to block LED light from hitting photodiode?
Do home values typically rise and fall at a consistent percent?
What will happen if I checked in for another room in the same hotel, but not for the booked one?
How to close/kill SSH connection when bash shell exits?
What steps does the system go through when handling an SSH connection?Kill backgrounded SSH when shell exitsHow does bash know how it is being invoked?Why does this shell script fail in bash, but the commands work in SSH?VNC/SSH: How to execute a command after logging in?specify shell for ssh sessionScript wont return when executed via SSHIBM AIX cannot view history in bash shellWhat exit modes exist in shell-scripting in general and in Bash in particular?Remote Commands and Restricted Shells via SSH
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
We are writing an application. As a part of it, we have to provide SSH access to each clients. In this process, we are providing SSH access to the client using a web UI. This ssh session is invoked from root user with some parameters, in such a way that the user shell is restricted to specific user permissions.
When the user exits the bash shell, it returns back to the root user. I want to terminate the ssh session when user exits the bash shell. How can I do this ?
bash shell bashrc
New contributor
add a comment |
We are writing an application. As a part of it, we have to provide SSH access to each clients. In this process, we are providing SSH access to the client using a web UI. This ssh session is invoked from root user with some parameters, in such a way that the user shell is restricted to specific user permissions.
When the user exits the bash shell, it returns back to the root user. I want to terminate the ssh session when user exits the bash shell. How can I do this ?
bash shell bashrc
New contributor
add a comment |
We are writing an application. As a part of it, we have to provide SSH access to each clients. In this process, we are providing SSH access to the client using a web UI. This ssh session is invoked from root user with some parameters, in such a way that the user shell is restricted to specific user permissions.
When the user exits the bash shell, it returns back to the root user. I want to terminate the ssh session when user exits the bash shell. How can I do this ?
bash shell bashrc
New contributor
We are writing an application. As a part of it, we have to provide SSH access to each clients. In this process, we are providing SSH access to the client using a web UI. This ssh session is invoked from root user with some parameters, in such a way that the user shell is restricted to specific user permissions.
When the user exits the bash shell, it returns back to the root user. I want to terminate the ssh session when user exits the bash shell. How can I do this ?
bash shell bashrc
bash shell bashrc
New contributor
New contributor
edited 23 mins ago
RalfFriedl
5,8303 gold badges12 silver badges25 bronze badges
5,8303 gold badges12 silver badges25 bronze badges
New contributor
asked 48 mins ago
jegan balujegan balu
1
1
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The SSH session will automatically close when the process that is started by the SSH server terminates.
If you have a script that prepares the session for the user, just call that with ssh -t server user-script
. The option -t
requests a terminal, that means the calling SSH client should have access to a terminal, unless terminal access doesn't matter for your client. In the last line of your script, use bash
or a little more efficiently exec bash
. As soon as that bash
terminates, the SSH session will be terminated.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});
}
});
jegan balu is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f527165%2fhow-to-close-kill-ssh-connection-when-bash-shell-exits%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The SSH session will automatically close when the process that is started by the SSH server terminates.
If you have a script that prepares the session for the user, just call that with ssh -t server user-script
. The option -t
requests a terminal, that means the calling SSH client should have access to a terminal, unless terminal access doesn't matter for your client. In the last line of your script, use bash
or a little more efficiently exec bash
. As soon as that bash
terminates, the SSH session will be terminated.
add a comment |
The SSH session will automatically close when the process that is started by the SSH server terminates.
If you have a script that prepares the session for the user, just call that with ssh -t server user-script
. The option -t
requests a terminal, that means the calling SSH client should have access to a terminal, unless terminal access doesn't matter for your client. In the last line of your script, use bash
or a little more efficiently exec bash
. As soon as that bash
terminates, the SSH session will be terminated.
add a comment |
The SSH session will automatically close when the process that is started by the SSH server terminates.
If you have a script that prepares the session for the user, just call that with ssh -t server user-script
. The option -t
requests a terminal, that means the calling SSH client should have access to a terminal, unless terminal access doesn't matter for your client. In the last line of your script, use bash
or a little more efficiently exec bash
. As soon as that bash
terminates, the SSH session will be terminated.
The SSH session will automatically close when the process that is started by the SSH server terminates.
If you have a script that prepares the session for the user, just call that with ssh -t server user-script
. The option -t
requests a terminal, that means the calling SSH client should have access to a terminal, unless terminal access doesn't matter for your client. In the last line of your script, use bash
or a little more efficiently exec bash
. As soon as that bash
terminates, the SSH session will be terminated.
answered 16 mins ago
RalfFriedlRalfFriedl
5,8303 gold badges12 silver badges25 bronze badges
5,8303 gold badges12 silver badges25 bronze badges
add a comment |
add a comment |
jegan balu is a new contributor. Be nice, and check out our Code of Conduct.
jegan balu is a new contributor. Be nice, and check out our Code of Conduct.
jegan balu is a new contributor. Be nice, and check out our Code of Conduct.
jegan balu is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f527165%2fhow-to-close-kill-ssh-connection-when-bash-shell-exits%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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