Is it possible to have conditional options in ~/.ssh/config based on the calling application (ssh or sshfs)?

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
In my ~/.ssh/config file I have the following option:
RemoteCommand /bin/sh -c 'tmux has-session && exec tmux attach || exec tmux'
This automatically starts tmux and connects to an existing session if possible when connecting via ssh.
This causes sshfs to fail to connect with the error read: Connection reset by peer.
Is there a way to apply this options selectively only when connecting with ssh and not when attempting to mount a filesystem with sshfs?
Note that I still want to load the remainder of the options in that file for sshfs, since they are still relevant. Using sshfs -F /dev/null is not an option.
I could of course create two separate configuration files for ssh and sshfs, but that would require a bunch of duplication that seems unecessary.
ssh sshfs ssh-config
add a comment |Â
up vote
1
down vote
favorite
In my ~/.ssh/config file I have the following option:
RemoteCommand /bin/sh -c 'tmux has-session && exec tmux attach || exec tmux'
This automatically starts tmux and connects to an existing session if possible when connecting via ssh.
This causes sshfs to fail to connect with the error read: Connection reset by peer.
Is there a way to apply this options selectively only when connecting with ssh and not when attempting to mount a filesystem with sshfs?
Note that I still want to load the remainder of the options in that file for sshfs, since they are still relevant. Using sshfs -F /dev/null is not an option.
I could of course create two separate configuration files for ssh and sshfs, but that would require a bunch of duplication that seems unecessary.
ssh sshfs ssh-config
In this case, you could change you RemoteCommand intty -s && tmux has-session && exec tmux attach || exec tmux. This way the command will execute only when an interactive session is started. This will solve your example problem but it does not answer your question.
â andcoz
Sep 5 at 13:35
@andcoz The tutorial that I lifted theRemoteCommandfrom actually specified to setRequestTTY yesas well, so I'm not sure that would help :-)
â maxf130
Sep 5 at 14:56
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In my ~/.ssh/config file I have the following option:
RemoteCommand /bin/sh -c 'tmux has-session && exec tmux attach || exec tmux'
This automatically starts tmux and connects to an existing session if possible when connecting via ssh.
This causes sshfs to fail to connect with the error read: Connection reset by peer.
Is there a way to apply this options selectively only when connecting with ssh and not when attempting to mount a filesystem with sshfs?
Note that I still want to load the remainder of the options in that file for sshfs, since they are still relevant. Using sshfs -F /dev/null is not an option.
I could of course create two separate configuration files for ssh and sshfs, but that would require a bunch of duplication that seems unecessary.
ssh sshfs ssh-config
In my ~/.ssh/config file I have the following option:
RemoteCommand /bin/sh -c 'tmux has-session && exec tmux attach || exec tmux'
This automatically starts tmux and connects to an existing session if possible when connecting via ssh.
This causes sshfs to fail to connect with the error read: Connection reset by peer.
Is there a way to apply this options selectively only when connecting with ssh and not when attempting to mount a filesystem with sshfs?
Note that I still want to load the remainder of the options in that file for sshfs, since they are still relevant. Using sshfs -F /dev/null is not an option.
I could of course create two separate configuration files for ssh and sshfs, but that would require a bunch of duplication that seems unecessary.
ssh sshfs ssh-config
ssh sshfs ssh-config
asked Sep 5 at 9:09
maxf130
1083
1083
In this case, you could change you RemoteCommand intty -s && tmux has-session && exec tmux attach || exec tmux. This way the command will execute only when an interactive session is started. This will solve your example problem but it does not answer your question.
â andcoz
Sep 5 at 13:35
@andcoz The tutorial that I lifted theRemoteCommandfrom actually specified to setRequestTTY yesas well, so I'm not sure that would help :-)
â maxf130
Sep 5 at 14:56
add a comment |Â
In this case, you could change you RemoteCommand intty -s && tmux has-session && exec tmux attach || exec tmux. This way the command will execute only when an interactive session is started. This will solve your example problem but it does not answer your question.
â andcoz
Sep 5 at 13:35
@andcoz The tutorial that I lifted theRemoteCommandfrom actually specified to setRequestTTY yesas well, so I'm not sure that would help :-)
â maxf130
Sep 5 at 14:56
In this case, you could change you RemoteCommand in
tty -s && tmux has-session && exec tmux attach || exec tmux . This way the command will execute only when an interactive session is started. This will solve your example problem but it does not answer your question.â andcoz
Sep 5 at 13:35
In this case, you could change you RemoteCommand in
tty -s && tmux has-session && exec tmux attach || exec tmux . This way the command will execute only when an interactive session is started. This will solve your example problem but it does not answer your question.â andcoz
Sep 5 at 13:35
@andcoz The tutorial that I lifted the
RemoteCommand from actually specified to set RequestTTY yes as well, so I'm not sure that would help :-)â maxf130
Sep 5 at 14:56
@andcoz The tutorial that I lifted the
RemoteCommand from actually specified to set RequestTTY yes as well, so I'm not sure that would help :-)â maxf130
Sep 5 at 14:56
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Suppose you used a different hostname when you want to use tmux eg
for sshfs :
ssh user@remotehost
but for tmux
ssh user@remotehost_tmux
and then in your ~/.ssh/config have a section specific for the host remotehost_tmux
eg.
# Global Options
#UseRoaming no
# Hostname specific options
Host <hostname>_tmux
RemoteCommand /bin/sh -c 'tmux has-session && exec tmux attach || exec tmux'
Hostname <hostname>
#
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Suppose you used a different hostname when you want to use tmux eg
for sshfs :
ssh user@remotehost
but for tmux
ssh user@remotehost_tmux
and then in your ~/.ssh/config have a section specific for the host remotehost_tmux
eg.
# Global Options
#UseRoaming no
# Hostname specific options
Host <hostname>_tmux
RemoteCommand /bin/sh -c 'tmux has-session && exec tmux attach || exec tmux'
Hostname <hostname>
#
add a comment |Â
up vote
1
down vote
accepted
Suppose you used a different hostname when you want to use tmux eg
for sshfs :
ssh user@remotehost
but for tmux
ssh user@remotehost_tmux
and then in your ~/.ssh/config have a section specific for the host remotehost_tmux
eg.
# Global Options
#UseRoaming no
# Hostname specific options
Host <hostname>_tmux
RemoteCommand /bin/sh -c 'tmux has-session && exec tmux attach || exec tmux'
Hostname <hostname>
#
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Suppose you used a different hostname when you want to use tmux eg
for sshfs :
ssh user@remotehost
but for tmux
ssh user@remotehost_tmux
and then in your ~/.ssh/config have a section specific for the host remotehost_tmux
eg.
# Global Options
#UseRoaming no
# Hostname specific options
Host <hostname>_tmux
RemoteCommand /bin/sh -c 'tmux has-session && exec tmux attach || exec tmux'
Hostname <hostname>
#
Suppose you used a different hostname when you want to use tmux eg
for sshfs :
ssh user@remotehost
but for tmux
ssh user@remotehost_tmux
and then in your ~/.ssh/config have a section specific for the host remotehost_tmux
eg.
# Global Options
#UseRoaming no
# Hostname specific options
Host <hostname>_tmux
RemoteCommand /bin/sh -c 'tmux has-session && exec tmux attach || exec tmux'
Hostname <hostname>
#
edited Sep 5 at 13:03
answered Sep 5 at 12:42
X Tian
7,34611836
7,34611836
add a comment |Â
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%2f466968%2fis-it-possible-to-have-conditional-options-in-ssh-config-based-on-the-calling%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
In this case, you could change you RemoteCommand in
tty -s && tmux has-session && exec tmux attach || exec tmux. This way the command will execute only when an interactive session is started. This will solve your example problem but it does not answer your question.â andcoz
Sep 5 at 13:35
@andcoz The tutorial that I lifted the
RemoteCommandfrom actually specified to setRequestTTY yesas well, so I'm not sure that would help :-)â maxf130
Sep 5 at 14:56