Configure default shell initialized by OpenSSH on Windows 7
up vote
4
down vote
favorite
Is there a way to configure OpenSSH on Windows 7 in to initialize another shell other than the default Windows command shell?
me@linuxhost:~
$ ssh me@windowshost
me@windowshost's password:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
me@windowshost C:Usersme> exit
Connection to windowshost closed.
me@linuxhost:~
$
Alternately, installing Cygwin and including OpenSSH in the additional Net packages results in a default Cygwin shell, so the same question stands: is there a way to configure the shell initialized by OpenSSH after installation?
EDIT:
Thank you @simlev for your suggestion to use Cygwin I have reworded my question to more clearly represent my problem.
ssh openssh sshd
add a comment |
up vote
4
down vote
favorite
Is there a way to configure OpenSSH on Windows 7 in to initialize another shell other than the default Windows command shell?
me@linuxhost:~
$ ssh me@windowshost
me@windowshost's password:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
me@windowshost C:Usersme> exit
Connection to windowshost closed.
me@linuxhost:~
$
Alternately, installing Cygwin and including OpenSSH in the additional Net packages results in a default Cygwin shell, so the same question stands: is there a way to configure the shell initialized by OpenSSH after installation?
EDIT:
Thank you @simlev for your suggestion to use Cygwin I have reworded my question to more clearly represent my problem.
ssh openssh sshd
You can do this easier with a dedicated tool. See for example if you like Gitblit.
– harrymc
Feb 27 '17 at 20:26
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
Is there a way to configure OpenSSH on Windows 7 in to initialize another shell other than the default Windows command shell?
me@linuxhost:~
$ ssh me@windowshost
me@windowshost's password:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
me@windowshost C:Usersme> exit
Connection to windowshost closed.
me@linuxhost:~
$
Alternately, installing Cygwin and including OpenSSH in the additional Net packages results in a default Cygwin shell, so the same question stands: is there a way to configure the shell initialized by OpenSSH after installation?
EDIT:
Thank you @simlev for your suggestion to use Cygwin I have reworded my question to more clearly represent my problem.
ssh openssh sshd
Is there a way to configure OpenSSH on Windows 7 in to initialize another shell other than the default Windows command shell?
me@linuxhost:~
$ ssh me@windowshost
me@windowshost's password:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
me@windowshost C:Usersme> exit
Connection to windowshost closed.
me@linuxhost:~
$
Alternately, installing Cygwin and including OpenSSH in the additional Net packages results in a default Cygwin shell, so the same question stands: is there a way to configure the shell initialized by OpenSSH after installation?
EDIT:
Thank you @simlev for your suggestion to use Cygwin I have reworded my question to more clearly represent my problem.
ssh openssh sshd
ssh openssh sshd
edited Feb 28 '17 at 17:58
asked Feb 24 '17 at 21:35
mlegge
739
739
You can do this easier with a dedicated tool. See for example if you like Gitblit.
– harrymc
Feb 27 '17 at 20:26
add a comment |
You can do this easier with a dedicated tool. See for example if you like Gitblit.
– harrymc
Feb 27 '17 at 20:26
You can do this easier with a dedicated tool. See for example if you like Gitblit.
– harrymc
Feb 27 '17 at 20:26
You can do this easier with a dedicated tool. See for example if you like Gitblit.
– harrymc
Feb 27 '17 at 20:26
add a comment |
3 Answers
3
active
oldest
votes
up vote
2
down vote
accepted
Win32-OpenSSH hardcodes cmd.exe as the default shell in the source: see lines 978-984 and 1081-1086 of shell-host.c. With that said, it appears the only way to change the default shell is to change it in those locations and recompile OpenSSH.
add a comment |
up vote
3
down vote
My warm recommendation is to use Cygwin to accept ssh connections on your Windows machine. This would allow you to scp to and from it, as well as login from a remote system via ssh to a Bash shell and command-line git.
user@linuxhost$ ssh 192.168.x.x
Last login: Sun Feb 12 08:20:07 2017 from 10.x.x.x
user@windowshost$ echo $0 && git --version
-bash
git version 2.8.3
The shell can of course be customized: ash, bash, dash and sh are included by default, but just run the Cygwin installer and you can add your choice of zsh, mksh, tcsh or posh. Then add the following line to /etc/nsswitch.conf:
db_shell: /bin/sh
possibly substituting /usr/bin/sh with the path to your preferred shell. All Cygwin processes (terminal windows and sshd service) must be restarted for the setting to take effect.
There is even a way to get a cmd or powershell prompt upon login, which I recently found out about on Stackoverflow.
- Download winpty for Cygwin and extract
winpty.exe,winpty.dllandwinpty-agent.exeto/bin. If you do this from outside of a Cygwin terminal, look for abinsubdirectory of the Cygwin installation folder.
Create two batch files in
/binand make sure they have execute permissions. Let's name them winpty-cmd.bat and winpty-powershell.bat and fill them with the following contents, where of course<cygwin path>is a placeholder for the path you installed Cygwin to (by default it'sC:cygwin):
@ECHO OFF
<cygwin path>binwinpty.exe cmd
and
@ECHO OFF
<cygwin path>binwinpty.exe powershell
Put one of these lines into
/etc/nsswitch.conf:
db_shell: /bin/winpty-cmd.bat
or
db_shell: /bin/winpty-powershell.bat
- Restart the sshd service.
Since the title has been "reworded" and my post might now seem sligthly out of place, allow me to directly answer the original question:
"Use git bash instead of cmd when sshing from Linux"
In addition to using Cygwin to accept ssh connections on the Windows machine:
- Follow step
1.above.
Create a file called
<cygwin path>binwinpty-gitbash.batwith these contents, where<cygwin path>is a placeholder for the path you installed git-for-windows to (by default it'sC:Program FilesGit):
@ECHO OFF
SET PATH="/bin"
<cygwin path>binwinpty.exe "<git path>binbash.exe"
Put this line into
/etc/nsswitch.conf:
db_shell: /bin/winpty-gitbash.bat
- Restart the sshd service.
This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).
– simlev
Feb 27 '17 at 19:35
add a comment |
up vote
0
down vote
According this you can configure the DefaultShell for OpenSSH in Windows, to be PowerShell or any other executable.
It requires to add the String Registry Key ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell with the path of the Shell Executable as string value, i.e.:
Powershell: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
CygWin Bash: C:Cygwin64binbash.exe
I tested it and works as expected.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fsuperuser.com%2fquestions%2f1182522%2fconfigure-default-shell-initialized-by-openssh-on-windows-7%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Win32-OpenSSH hardcodes cmd.exe as the default shell in the source: see lines 978-984 and 1081-1086 of shell-host.c. With that said, it appears the only way to change the default shell is to change it in those locations and recompile OpenSSH.
add a comment |
up vote
2
down vote
accepted
Win32-OpenSSH hardcodes cmd.exe as the default shell in the source: see lines 978-984 and 1081-1086 of shell-host.c. With that said, it appears the only way to change the default shell is to change it in those locations and recompile OpenSSH.
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Win32-OpenSSH hardcodes cmd.exe as the default shell in the source: see lines 978-984 and 1081-1086 of shell-host.c. With that said, it appears the only way to change the default shell is to change it in those locations and recompile OpenSSH.
Win32-OpenSSH hardcodes cmd.exe as the default shell in the source: see lines 978-984 and 1081-1086 of shell-host.c. With that said, it appears the only way to change the default shell is to change it in those locations and recompile OpenSSH.
answered Mar 2 '17 at 5:10
Joseph Sible
981114
981114
add a comment |
add a comment |
up vote
3
down vote
My warm recommendation is to use Cygwin to accept ssh connections on your Windows machine. This would allow you to scp to and from it, as well as login from a remote system via ssh to a Bash shell and command-line git.
user@linuxhost$ ssh 192.168.x.x
Last login: Sun Feb 12 08:20:07 2017 from 10.x.x.x
user@windowshost$ echo $0 && git --version
-bash
git version 2.8.3
The shell can of course be customized: ash, bash, dash and sh are included by default, but just run the Cygwin installer and you can add your choice of zsh, mksh, tcsh or posh. Then add the following line to /etc/nsswitch.conf:
db_shell: /bin/sh
possibly substituting /usr/bin/sh with the path to your preferred shell. All Cygwin processes (terminal windows and sshd service) must be restarted for the setting to take effect.
There is even a way to get a cmd or powershell prompt upon login, which I recently found out about on Stackoverflow.
- Download winpty for Cygwin and extract
winpty.exe,winpty.dllandwinpty-agent.exeto/bin. If you do this from outside of a Cygwin terminal, look for abinsubdirectory of the Cygwin installation folder.
Create two batch files in
/binand make sure they have execute permissions. Let's name them winpty-cmd.bat and winpty-powershell.bat and fill them with the following contents, where of course<cygwin path>is a placeholder for the path you installed Cygwin to (by default it'sC:cygwin):
@ECHO OFF
<cygwin path>binwinpty.exe cmd
and
@ECHO OFF
<cygwin path>binwinpty.exe powershell
Put one of these lines into
/etc/nsswitch.conf:
db_shell: /bin/winpty-cmd.bat
or
db_shell: /bin/winpty-powershell.bat
- Restart the sshd service.
Since the title has been "reworded" and my post might now seem sligthly out of place, allow me to directly answer the original question:
"Use git bash instead of cmd when sshing from Linux"
In addition to using Cygwin to accept ssh connections on the Windows machine:
- Follow step
1.above.
Create a file called
<cygwin path>binwinpty-gitbash.batwith these contents, where<cygwin path>is a placeholder for the path you installed git-for-windows to (by default it'sC:Program FilesGit):
@ECHO OFF
SET PATH="/bin"
<cygwin path>binwinpty.exe "<git path>binbash.exe"
Put this line into
/etc/nsswitch.conf:
db_shell: /bin/winpty-gitbash.bat
- Restart the sshd service.
This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).
– simlev
Feb 27 '17 at 19:35
add a comment |
up vote
3
down vote
My warm recommendation is to use Cygwin to accept ssh connections on your Windows machine. This would allow you to scp to and from it, as well as login from a remote system via ssh to a Bash shell and command-line git.
user@linuxhost$ ssh 192.168.x.x
Last login: Sun Feb 12 08:20:07 2017 from 10.x.x.x
user@windowshost$ echo $0 && git --version
-bash
git version 2.8.3
The shell can of course be customized: ash, bash, dash and sh are included by default, but just run the Cygwin installer and you can add your choice of zsh, mksh, tcsh or posh. Then add the following line to /etc/nsswitch.conf:
db_shell: /bin/sh
possibly substituting /usr/bin/sh with the path to your preferred shell. All Cygwin processes (terminal windows and sshd service) must be restarted for the setting to take effect.
There is even a way to get a cmd or powershell prompt upon login, which I recently found out about on Stackoverflow.
- Download winpty for Cygwin and extract
winpty.exe,winpty.dllandwinpty-agent.exeto/bin. If you do this from outside of a Cygwin terminal, look for abinsubdirectory of the Cygwin installation folder.
Create two batch files in
/binand make sure they have execute permissions. Let's name them winpty-cmd.bat and winpty-powershell.bat and fill them with the following contents, where of course<cygwin path>is a placeholder for the path you installed Cygwin to (by default it'sC:cygwin):
@ECHO OFF
<cygwin path>binwinpty.exe cmd
and
@ECHO OFF
<cygwin path>binwinpty.exe powershell
Put one of these lines into
/etc/nsswitch.conf:
db_shell: /bin/winpty-cmd.bat
or
db_shell: /bin/winpty-powershell.bat
- Restart the sshd service.
Since the title has been "reworded" and my post might now seem sligthly out of place, allow me to directly answer the original question:
"Use git bash instead of cmd when sshing from Linux"
In addition to using Cygwin to accept ssh connections on the Windows machine:
- Follow step
1.above.
Create a file called
<cygwin path>binwinpty-gitbash.batwith these contents, where<cygwin path>is a placeholder for the path you installed git-for-windows to (by default it'sC:Program FilesGit):
@ECHO OFF
SET PATH="/bin"
<cygwin path>binwinpty.exe "<git path>binbash.exe"
Put this line into
/etc/nsswitch.conf:
db_shell: /bin/winpty-gitbash.bat
- Restart the sshd service.
This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).
– simlev
Feb 27 '17 at 19:35
add a comment |
up vote
3
down vote
up vote
3
down vote
My warm recommendation is to use Cygwin to accept ssh connections on your Windows machine. This would allow you to scp to and from it, as well as login from a remote system via ssh to a Bash shell and command-line git.
user@linuxhost$ ssh 192.168.x.x
Last login: Sun Feb 12 08:20:07 2017 from 10.x.x.x
user@windowshost$ echo $0 && git --version
-bash
git version 2.8.3
The shell can of course be customized: ash, bash, dash and sh are included by default, but just run the Cygwin installer and you can add your choice of zsh, mksh, tcsh or posh. Then add the following line to /etc/nsswitch.conf:
db_shell: /bin/sh
possibly substituting /usr/bin/sh with the path to your preferred shell. All Cygwin processes (terminal windows and sshd service) must be restarted for the setting to take effect.
There is even a way to get a cmd or powershell prompt upon login, which I recently found out about on Stackoverflow.
- Download winpty for Cygwin and extract
winpty.exe,winpty.dllandwinpty-agent.exeto/bin. If you do this from outside of a Cygwin terminal, look for abinsubdirectory of the Cygwin installation folder.
Create two batch files in
/binand make sure they have execute permissions. Let's name them winpty-cmd.bat and winpty-powershell.bat and fill them with the following contents, where of course<cygwin path>is a placeholder for the path you installed Cygwin to (by default it'sC:cygwin):
@ECHO OFF
<cygwin path>binwinpty.exe cmd
and
@ECHO OFF
<cygwin path>binwinpty.exe powershell
Put one of these lines into
/etc/nsswitch.conf:
db_shell: /bin/winpty-cmd.bat
or
db_shell: /bin/winpty-powershell.bat
- Restart the sshd service.
Since the title has been "reworded" and my post might now seem sligthly out of place, allow me to directly answer the original question:
"Use git bash instead of cmd when sshing from Linux"
In addition to using Cygwin to accept ssh connections on the Windows machine:
- Follow step
1.above.
Create a file called
<cygwin path>binwinpty-gitbash.batwith these contents, where<cygwin path>is a placeholder for the path you installed git-for-windows to (by default it'sC:Program FilesGit):
@ECHO OFF
SET PATH="/bin"
<cygwin path>binwinpty.exe "<git path>binbash.exe"
Put this line into
/etc/nsswitch.conf:
db_shell: /bin/winpty-gitbash.bat
- Restart the sshd service.
My warm recommendation is to use Cygwin to accept ssh connections on your Windows machine. This would allow you to scp to and from it, as well as login from a remote system via ssh to a Bash shell and command-line git.
user@linuxhost$ ssh 192.168.x.x
Last login: Sun Feb 12 08:20:07 2017 from 10.x.x.x
user@windowshost$ echo $0 && git --version
-bash
git version 2.8.3
The shell can of course be customized: ash, bash, dash and sh are included by default, but just run the Cygwin installer and you can add your choice of zsh, mksh, tcsh or posh. Then add the following line to /etc/nsswitch.conf:
db_shell: /bin/sh
possibly substituting /usr/bin/sh with the path to your preferred shell. All Cygwin processes (terminal windows and sshd service) must be restarted for the setting to take effect.
There is even a way to get a cmd or powershell prompt upon login, which I recently found out about on Stackoverflow.
- Download winpty for Cygwin and extract
winpty.exe,winpty.dllandwinpty-agent.exeto/bin. If you do this from outside of a Cygwin terminal, look for abinsubdirectory of the Cygwin installation folder.
Create two batch files in
/binand make sure they have execute permissions. Let's name them winpty-cmd.bat and winpty-powershell.bat and fill them with the following contents, where of course<cygwin path>is a placeholder for the path you installed Cygwin to (by default it'sC:cygwin):
@ECHO OFF
<cygwin path>binwinpty.exe cmd
and
@ECHO OFF
<cygwin path>binwinpty.exe powershell
Put one of these lines into
/etc/nsswitch.conf:
db_shell: /bin/winpty-cmd.bat
or
db_shell: /bin/winpty-powershell.bat
- Restart the sshd service.
Since the title has been "reworded" and my post might now seem sligthly out of place, allow me to directly answer the original question:
"Use git bash instead of cmd when sshing from Linux"
In addition to using Cygwin to accept ssh connections on the Windows machine:
- Follow step
1.above.
Create a file called
<cygwin path>binwinpty-gitbash.batwith these contents, where<cygwin path>is a placeholder for the path you installed git-for-windows to (by default it'sC:Program FilesGit):
@ECHO OFF
SET PATH="/bin"
<cygwin path>binwinpty.exe "<git path>binbash.exe"
Put this line into
/etc/nsswitch.conf:
db_shell: /bin/winpty-gitbash.bat
- Restart the sshd service.
edited May 23 '17 at 11:33
Community♦
1
1
answered Feb 27 '17 at 19:03
simlev
3,0063527
3,0063527
This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).
– simlev
Feb 27 '17 at 19:35
add a comment |
This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).
– simlev
Feb 27 '17 at 19:35
This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).
– simlev
Feb 27 '17 at 19:35
This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).
– simlev
Feb 27 '17 at 19:35
add a comment |
up vote
0
down vote
According this you can configure the DefaultShell for OpenSSH in Windows, to be PowerShell or any other executable.
It requires to add the String Registry Key ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell with the path of the Shell Executable as string value, i.e.:
Powershell: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
CygWin Bash: C:Cygwin64binbash.exe
I tested it and works as expected.
add a comment |
up vote
0
down vote
According this you can configure the DefaultShell for OpenSSH in Windows, to be PowerShell or any other executable.
It requires to add the String Registry Key ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell with the path of the Shell Executable as string value, i.e.:
Powershell: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
CygWin Bash: C:Cygwin64binbash.exe
I tested it and works as expected.
add a comment |
up vote
0
down vote
up vote
0
down vote
According this you can configure the DefaultShell for OpenSSH in Windows, to be PowerShell or any other executable.
It requires to add the String Registry Key ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell with the path of the Shell Executable as string value, i.e.:
Powershell: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
CygWin Bash: C:Cygwin64binbash.exe
I tested it and works as expected.
According this you can configure the DefaultShell for OpenSSH in Windows, to be PowerShell or any other executable.
It requires to add the String Registry Key ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell with the path of the Shell Executable as string value, i.e.:
Powershell: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
CygWin Bash: C:Cygwin64binbash.exe
I tested it and works as expected.
answered Dec 7 at 1:08
Brethlosze
1157
1157
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fsuperuser.com%2fquestions%2f1182522%2fconfigure-default-shell-initialized-by-openssh-on-windows-7%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
You can do this easier with a dedicated tool. See for example if you like Gitblit.
– harrymc
Feb 27 '17 at 20:26