Executing a remote command
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
I can't edit the .bashrc of the fs I'm connecting to
I have to use the
~/.ssh/config
file
Here is my current config:
Host my-ssh
HostName <ip>
User <user>
IdentityFile <file location>
Compression yes
RemoteCommand cd <path to folder>
When I run ssh my-ssh
nothing happens. The connection seems to automatically close. If I remove the RemoteCommand
line it connects without an issue.
Is this something on the server config? It's an EC2 instance, either CentOS or RHEL and bash is the shell.
linux bash ssh remote aws
add a comment |Â
up vote
4
down vote
favorite
I can't edit the .bashrc of the fs I'm connecting to
I have to use the
~/.ssh/config
file
Here is my current config:
Host my-ssh
HostName <ip>
User <user>
IdentityFile <file location>
Compression yes
RemoteCommand cd <path to folder>
When I run ssh my-ssh
nothing happens. The connection seems to automatically close. If I remove the RemoteCommand
line it connects without an issue.
Is this something on the server config? It's an EC2 instance, either CentOS or RHEL and bash is the shell.
linux bash ssh remote aws
The list you've entered is in a desktop shortcut?man ssh
to find out how to specify those items on a command line. Is this homework?
â Xalorous
Jan 23 at 21:56
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I can't edit the .bashrc of the fs I'm connecting to
I have to use the
~/.ssh/config
file
Here is my current config:
Host my-ssh
HostName <ip>
User <user>
IdentityFile <file location>
Compression yes
RemoteCommand cd <path to folder>
When I run ssh my-ssh
nothing happens. The connection seems to automatically close. If I remove the RemoteCommand
line it connects without an issue.
Is this something on the server config? It's an EC2 instance, either CentOS or RHEL and bash is the shell.
linux bash ssh remote aws
I can't edit the .bashrc of the fs I'm connecting to
I have to use the
~/.ssh/config
file
Here is my current config:
Host my-ssh
HostName <ip>
User <user>
IdentityFile <file location>
Compression yes
RemoteCommand cd <path to folder>
When I run ssh my-ssh
nothing happens. The connection seems to automatically close. If I remove the RemoteCommand
line it connects without an issue.
Is this something on the server config? It's an EC2 instance, either CentOS or RHEL and bash is the shell.
linux bash ssh remote aws
edited Jan 24 at 11:43
Jeff Schaller
31.7k847107
31.7k847107
asked Jan 23 at 21:49
Robbie Milejczak
1286
1286
The list you've entered is in a desktop shortcut?man ssh
to find out how to specify those items on a command line. Is this homework?
â Xalorous
Jan 23 at 21:56
add a comment |Â
The list you've entered is in a desktop shortcut?man ssh
to find out how to specify those items on a command line. Is this homework?
â Xalorous
Jan 23 at 21:56
The list you've entered is in a desktop shortcut?
man ssh
to find out how to specify those items on a command line. Is this homework?â Xalorous
Jan 23 at 21:56
The list you've entered is in a desktop shortcut?
man ssh
to find out how to specify those items on a command line. Is this homework?â Xalorous
Jan 23 at 21:56
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
7
down vote
accepted
If you specify a remote command, then the ssh connection is going to close as soon as the remote command exits. A cd
command will exit almost immediately.
A common way to do what you want is:
RemoteCommand cd /some/path && bash
(Substitute your desired shell in place of "bash"). This cd's to the path and then invokes a subshell if the cd operation succeeded. The ssh connection will close when the subshell exits.
You will also want to force ssh to allocate a PTY for the session:
RequestTTY yes
If you don't, then ssh won't request one by default, and you'll get a non-interactive shell session. Notably, you won't get a command prompt.
add a comment |Â
up vote
3
down vote
If you have a RemoteCommand
specified it is the same as the following:
ssh user@host <command>
What happens is that ssh
connects to the host, runs the command and exits, and returns the exit status of the command as the exit status of ssh
.
From the man page:
If command is specified, it is executed on the remote host instead of a login shell.
So you are logging into the host, changing directory and then ssh
is exiting. I doubt this is what you want. Remote command is non-interactive, i.e. to run one specific command on a remote machine.
add a comment |Â
up vote
-2
down vote
Try to run ssh -t my-ssh
. You may need to force pseudo terminal allocation which is ommitted by the config in ~/.ssh/config.
this is not complete, as the asker needs also to do something more than just issuing acd ...
(which then exits, ending the session)
â thrig
Jan 23 at 22:17
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
accepted
If you specify a remote command, then the ssh connection is going to close as soon as the remote command exits. A cd
command will exit almost immediately.
A common way to do what you want is:
RemoteCommand cd /some/path && bash
(Substitute your desired shell in place of "bash"). This cd's to the path and then invokes a subshell if the cd operation succeeded. The ssh connection will close when the subshell exits.
You will also want to force ssh to allocate a PTY for the session:
RequestTTY yes
If you don't, then ssh won't request one by default, and you'll get a non-interactive shell session. Notably, you won't get a command prompt.
add a comment |Â
up vote
7
down vote
accepted
If you specify a remote command, then the ssh connection is going to close as soon as the remote command exits. A cd
command will exit almost immediately.
A common way to do what you want is:
RemoteCommand cd /some/path && bash
(Substitute your desired shell in place of "bash"). This cd's to the path and then invokes a subshell if the cd operation succeeded. The ssh connection will close when the subshell exits.
You will also want to force ssh to allocate a PTY for the session:
RequestTTY yes
If you don't, then ssh won't request one by default, and you'll get a non-interactive shell session. Notably, you won't get a command prompt.
add a comment |Â
up vote
7
down vote
accepted
up vote
7
down vote
accepted
If you specify a remote command, then the ssh connection is going to close as soon as the remote command exits. A cd
command will exit almost immediately.
A common way to do what you want is:
RemoteCommand cd /some/path && bash
(Substitute your desired shell in place of "bash"). This cd's to the path and then invokes a subshell if the cd operation succeeded. The ssh connection will close when the subshell exits.
You will also want to force ssh to allocate a PTY for the session:
RequestTTY yes
If you don't, then ssh won't request one by default, and you'll get a non-interactive shell session. Notably, you won't get a command prompt.
If you specify a remote command, then the ssh connection is going to close as soon as the remote command exits. A cd
command will exit almost immediately.
A common way to do what you want is:
RemoteCommand cd /some/path && bash
(Substitute your desired shell in place of "bash"). This cd's to the path and then invokes a subshell if the cd operation succeeded. The ssh connection will close when the subshell exits.
You will also want to force ssh to allocate a PTY for the session:
RequestTTY yes
If you don't, then ssh won't request one by default, and you'll get a non-interactive shell session. Notably, you won't get a command prompt.
answered Jan 23 at 22:14
Kenster
1,3281611
1,3281611
add a comment |Â
add a comment |Â
up vote
3
down vote
If you have a RemoteCommand
specified it is the same as the following:
ssh user@host <command>
What happens is that ssh
connects to the host, runs the command and exits, and returns the exit status of the command as the exit status of ssh
.
From the man page:
If command is specified, it is executed on the remote host instead of a login shell.
So you are logging into the host, changing directory and then ssh
is exiting. I doubt this is what you want. Remote command is non-interactive, i.e. to run one specific command on a remote machine.
add a comment |Â
up vote
3
down vote
If you have a RemoteCommand
specified it is the same as the following:
ssh user@host <command>
What happens is that ssh
connects to the host, runs the command and exits, and returns the exit status of the command as the exit status of ssh
.
From the man page:
If command is specified, it is executed on the remote host instead of a login shell.
So you are logging into the host, changing directory and then ssh
is exiting. I doubt this is what you want. Remote command is non-interactive, i.e. to run one specific command on a remote machine.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
If you have a RemoteCommand
specified it is the same as the following:
ssh user@host <command>
What happens is that ssh
connects to the host, runs the command and exits, and returns the exit status of the command as the exit status of ssh
.
From the man page:
If command is specified, it is executed on the remote host instead of a login shell.
So you are logging into the host, changing directory and then ssh
is exiting. I doubt this is what you want. Remote command is non-interactive, i.e. to run one specific command on a remote machine.
If you have a RemoteCommand
specified it is the same as the following:
ssh user@host <command>
What happens is that ssh
connects to the host, runs the command and exits, and returns the exit status of the command as the exit status of ssh
.
From the man page:
If command is specified, it is executed on the remote host instead of a login shell.
So you are logging into the host, changing directory and then ssh
is exiting. I doubt this is what you want. Remote command is non-interactive, i.e. to run one specific command on a remote machine.
edited Jan 23 at 22:10
answered Jan 23 at 22:05
datUser
2,2811032
2,2811032
add a comment |Â
add a comment |Â
up vote
-2
down vote
Try to run ssh -t my-ssh
. You may need to force pseudo terminal allocation which is ommitted by the config in ~/.ssh/config.
this is not complete, as the asker needs also to do something more than just issuing acd ...
(which then exits, ending the session)
â thrig
Jan 23 at 22:17
add a comment |Â
up vote
-2
down vote
Try to run ssh -t my-ssh
. You may need to force pseudo terminal allocation which is ommitted by the config in ~/.ssh/config.
this is not complete, as the asker needs also to do something more than just issuing acd ...
(which then exits, ending the session)
â thrig
Jan 23 at 22:17
add a comment |Â
up vote
-2
down vote
up vote
-2
down vote
Try to run ssh -t my-ssh
. You may need to force pseudo terminal allocation which is ommitted by the config in ~/.ssh/config.
Try to run ssh -t my-ssh
. You may need to force pseudo terminal allocation which is ommitted by the config in ~/.ssh/config.
answered Jan 23 at 22:10
grinnan
1
1
this is not complete, as the asker needs also to do something more than just issuing acd ...
(which then exits, ending the session)
â thrig
Jan 23 at 22:17
add a comment |Â
this is not complete, as the asker needs also to do something more than just issuing acd ...
(which then exits, ending the session)
â thrig
Jan 23 at 22:17
this is not complete, as the asker needs also to do something more than just issuing a
cd ...
(which then exits, ending the session)â thrig
Jan 23 at 22:17
this is not complete, as the asker needs also to do something more than just issuing a
cd ...
(which then exits, ending the session)â thrig
Jan 23 at 22:17
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f419198%2fexecuting-a-remote-command%23new-answer', 'question_page');
);
Post as a guest
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
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
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
The list you've entered is in a desktop shortcut?
man ssh
to find out how to specify those items on a command line. Is this homework?â Xalorous
Jan 23 at 21:56