Can an ssh client connect to an existing shell running on a remote machine?
Whenever I ssh to a remote machine, it always creates a new remote shell.
Can an ssh client connect to an existing shell running on a remote machine?
shell ssh
add a comment |
Whenever I ssh to a remote machine, it always creates a new remote shell.
Can an ssh client connect to an existing shell running on a remote machine?
shell ssh
No. That's not how Unix works, in any way shape or form.
– Stephen Harris
Mar 1 at 2:46
5
what you can do is runscreen
ortmux
on the remote server. That allows you to detach and re-attach to a session that has a shell inside it.
– glenn jackman
Mar 1 at 3:22
@炸鱼薯条德里克 that's out of line. unix.stackexchange.com/conduct
– terdon♦
Mar 1 at 9:24
add a comment |
Whenever I ssh to a remote machine, it always creates a new remote shell.
Can an ssh client connect to an existing shell running on a remote machine?
shell ssh
Whenever I ssh to a remote machine, it always creates a new remote shell.
Can an ssh client connect to an existing shell running on a remote machine?
shell ssh
shell ssh
edited 23 mins ago
Jeff Schaller
43.4k1160140
43.4k1160140
asked Mar 1 at 2:41
TimTim
27.7k78265483
27.7k78265483
No. That's not how Unix works, in any way shape or form.
– Stephen Harris
Mar 1 at 2:46
5
what you can do is runscreen
ortmux
on the remote server. That allows you to detach and re-attach to a session that has a shell inside it.
– glenn jackman
Mar 1 at 3:22
@炸鱼薯条德里克 that's out of line. unix.stackexchange.com/conduct
– terdon♦
Mar 1 at 9:24
add a comment |
No. That's not how Unix works, in any way shape or form.
– Stephen Harris
Mar 1 at 2:46
5
what you can do is runscreen
ortmux
on the remote server. That allows you to detach and re-attach to a session that has a shell inside it.
– glenn jackman
Mar 1 at 3:22
@炸鱼薯条德里克 that's out of line. unix.stackexchange.com/conduct
– terdon♦
Mar 1 at 9:24
No. That's not how Unix works, in any way shape or form.
– Stephen Harris
Mar 1 at 2:46
No. That's not how Unix works, in any way shape or form.
– Stephen Harris
Mar 1 at 2:46
5
5
what you can do is run
screen
or tmux
on the remote server. That allows you to detach and re-attach to a session that has a shell inside it.– glenn jackman
Mar 1 at 3:22
what you can do is run
screen
or tmux
on the remote server. That allows you to detach and re-attach to a session that has a shell inside it.– glenn jackman
Mar 1 at 3:22
@炸鱼薯条德里克 that's out of line. unix.stackexchange.com/conduct
– terdon♦
Mar 1 at 9:24
@炸鱼薯条德里克 that's out of line. unix.stackexchange.com/conduct
– terdon♦
Mar 1 at 9:24
add a comment |
1 Answer
1
active
oldest
votes
No, an ssh client cannot connect to an existing, running shell.
The Secure Shell Connection Protocol specifies that an interactive session is:
A session is a remote execution of a program. The program may be:
- a shell,
- an application,
- a system command,
- or some built-in subsystem.
It may or may not have a tty, and may or may not involve X11 forwarding. Multiple sessions can be active simultaneously.
It goes on to clarify, in Starting a Shell or a Command (my emphasis):
Once the session has been set up, a program is started at the remote end. The program can be a shell, an application program, or a subsystem with a host-independent name. Only one of these requests can succeed per channel.
The document then illustrates how the client can request (my emphasis again):
- a "shell", which "will request that the user's default shell (typically
defined in /etc/passwd in UNIX systems) be started at the other end", or - "exec", which "will request that the server start the execution of the
given command.", or - "subsystem", which "executes a predefined subsystem" (such as sftp)
As a result, an ssh connection can only start a new shell.
As one comment indicated, you could emulate the behavior of connecting to an existing shell by creating a screen
or tmux
session on the remote side, then connecting to that remote system via ssh
(creating a new $SHELL instance!), and then using screen
or tmux
commands in that new shell to attach to the existing session.
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
});
}
});
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%2f503674%2fcan-an-ssh-client-connect-to-an-existing-shell-running-on-a-remote-machine%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
No, an ssh client cannot connect to an existing, running shell.
The Secure Shell Connection Protocol specifies that an interactive session is:
A session is a remote execution of a program. The program may be:
- a shell,
- an application,
- a system command,
- or some built-in subsystem.
It may or may not have a tty, and may or may not involve X11 forwarding. Multiple sessions can be active simultaneously.
It goes on to clarify, in Starting a Shell or a Command (my emphasis):
Once the session has been set up, a program is started at the remote end. The program can be a shell, an application program, or a subsystem with a host-independent name. Only one of these requests can succeed per channel.
The document then illustrates how the client can request (my emphasis again):
- a "shell", which "will request that the user's default shell (typically
defined in /etc/passwd in UNIX systems) be started at the other end", or - "exec", which "will request that the server start the execution of the
given command.", or - "subsystem", which "executes a predefined subsystem" (such as sftp)
As a result, an ssh connection can only start a new shell.
As one comment indicated, you could emulate the behavior of connecting to an existing shell by creating a screen
or tmux
session on the remote side, then connecting to that remote system via ssh
(creating a new $SHELL instance!), and then using screen
or tmux
commands in that new shell to attach to the existing session.
add a comment |
No, an ssh client cannot connect to an existing, running shell.
The Secure Shell Connection Protocol specifies that an interactive session is:
A session is a remote execution of a program. The program may be:
- a shell,
- an application,
- a system command,
- or some built-in subsystem.
It may or may not have a tty, and may or may not involve X11 forwarding. Multiple sessions can be active simultaneously.
It goes on to clarify, in Starting a Shell or a Command (my emphasis):
Once the session has been set up, a program is started at the remote end. The program can be a shell, an application program, or a subsystem with a host-independent name. Only one of these requests can succeed per channel.
The document then illustrates how the client can request (my emphasis again):
- a "shell", which "will request that the user's default shell (typically
defined in /etc/passwd in UNIX systems) be started at the other end", or - "exec", which "will request that the server start the execution of the
given command.", or - "subsystem", which "executes a predefined subsystem" (such as sftp)
As a result, an ssh connection can only start a new shell.
As one comment indicated, you could emulate the behavior of connecting to an existing shell by creating a screen
or tmux
session on the remote side, then connecting to that remote system via ssh
(creating a new $SHELL instance!), and then using screen
or tmux
commands in that new shell to attach to the existing session.
add a comment |
No, an ssh client cannot connect to an existing, running shell.
The Secure Shell Connection Protocol specifies that an interactive session is:
A session is a remote execution of a program. The program may be:
- a shell,
- an application,
- a system command,
- or some built-in subsystem.
It may or may not have a tty, and may or may not involve X11 forwarding. Multiple sessions can be active simultaneously.
It goes on to clarify, in Starting a Shell or a Command (my emphasis):
Once the session has been set up, a program is started at the remote end. The program can be a shell, an application program, or a subsystem with a host-independent name. Only one of these requests can succeed per channel.
The document then illustrates how the client can request (my emphasis again):
- a "shell", which "will request that the user's default shell (typically
defined in /etc/passwd in UNIX systems) be started at the other end", or - "exec", which "will request that the server start the execution of the
given command.", or - "subsystem", which "executes a predefined subsystem" (such as sftp)
As a result, an ssh connection can only start a new shell.
As one comment indicated, you could emulate the behavior of connecting to an existing shell by creating a screen
or tmux
session on the remote side, then connecting to that remote system via ssh
(creating a new $SHELL instance!), and then using screen
or tmux
commands in that new shell to attach to the existing session.
No, an ssh client cannot connect to an existing, running shell.
The Secure Shell Connection Protocol specifies that an interactive session is:
A session is a remote execution of a program. The program may be:
- a shell,
- an application,
- a system command,
- or some built-in subsystem.
It may or may not have a tty, and may or may not involve X11 forwarding. Multiple sessions can be active simultaneously.
It goes on to clarify, in Starting a Shell or a Command (my emphasis):
Once the session has been set up, a program is started at the remote end. The program can be a shell, an application program, or a subsystem with a host-independent name. Only one of these requests can succeed per channel.
The document then illustrates how the client can request (my emphasis again):
- a "shell", which "will request that the user's default shell (typically
defined in /etc/passwd in UNIX systems) be started at the other end", or - "exec", which "will request that the server start the execution of the
given command.", or - "subsystem", which "executes a predefined subsystem" (such as sftp)
As a result, an ssh connection can only start a new shell.
As one comment indicated, you could emulate the behavior of connecting to an existing shell by creating a screen
or tmux
session on the remote side, then connecting to that remote system via ssh
(creating a new $SHELL instance!), and then using screen
or tmux
commands in that new shell to attach to the existing session.
answered 23 mins ago
Jeff SchallerJeff Schaller
43.4k1160140
43.4k1160140
add a comment |
add a comment |
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%2f503674%2fcan-an-ssh-client-connect-to-an-existing-shell-running-on-a-remote-machine%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
No. That's not how Unix works, in any way shape or form.
– Stephen Harris
Mar 1 at 2:46
5
what you can do is run
screen
ortmux
on the remote server. That allows you to detach and re-attach to a session that has a shell inside it.– glenn jackman
Mar 1 at 3:22
@炸鱼薯条德里克 that's out of line. unix.stackexchange.com/conduct
– terdon♦
Mar 1 at 9:24