You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reacted by Sergey Kostrukov, Chris Charabaruk, Ritch Melton, bryfry, kvishnukant, Arthur Jiang, m0ppers, Lucas Theisen, Vitalii Kovalchuk, Diogo Pereira and 5 more
Alexandru Duzsardi (@aduzsardi) using ForceCommand powershell.exe will help just to interactive session but it breaks things like SFTP. Try to do SFTP connection to server which has ForceCommand enabled, SFTP won't be happy with powershell logo message :-)
Reacted by Diogo Pereira, Andreas Gnau, Alexander Håkansson and Alexandru Duzsardi
Read the default SSH shell from an user environment variable that has the full path (ex - C:\Windows\System32\cmd.exe)
Check if the default SSH shell is trusted,
a) If the executable is from system32 path (ex - C:\Windows\System32)
(or)
b) If the executable is published from a trusted source (ex - Microsoft).
If step 2 succeeds then launch the default SSH shell.
If step 2 fails then launch the cmd.exe
Issue with this proposal,
If a user has unpublished powershell.exe, step-2 will fail and we end up launching cmd.exe..
We would like to hear from the community, alternative proposals or any suggestions..
Anything that can be done to make powershell the default will be good for me, but I wonder how the SSH shell from an user environment variable will get set... I usually set environment variables in my user profile, but the won't get executed until powershell starts...
Looks like powershell.exe from powershell core is not signed by Microsoft (at least beta 4), so does that mean it would have to be installed under system32 to work with OpenSSH?
What does "trusted" mean in this context?
In the past Microsoft has considered "Program Files" locations more trustworthy than user writable locations because it takes admin permissions to place something there.
The intention here is address the security concern around "sshd launching malware injected arbitrary session process". Sticking with cmd.exe keeps it plain simple.
Otherwise we are trying to understand if there are any specific requirements mandating Powershell by default (apart from the convenience aspect). I see a drawback - its difficult to adjust Powershell session prompt (PS:>) to make it identify a remote session (like we do for cmd.exe).
BTW, Powershell could be launched straight away as follows
ssh.exe -t user@target powershell
Manoj Ampalam (@manojampalam) was there an update to support this?
Using this command puts the local terminal in a forever waiting state.
The server then climbs CPU usage
Scratch (@Scrxtchy) please open a new issue for what you are seeing. That's not expected (I don't see it on my end). Fill in the template and we'll take it forward.
Can't you set the COMSPEC variable to powershell.exe and use that? (I admit that I left Windows behind before the switch to NT/XP, so this may be outdated knowledge)
There can be a situation where the default shell has to be PowerShell for ssh sessions but other applications still needs the default shell as cmd.exe..
As mentioned earlier one of our proposals is to use a new environment variable instead of COMPSPEC.
Also we need to add few security checks when we start using environment variables as any malware can modify the environment variable thus causing a security threat.
There can be a situation where the default shell has to be PowerShell for ssh sessions but other applications still needs the default shell as cmd.exe..
If there is such a use case (which one?), wouldn't it be enough to instruct those users to write their own wrapper that checks whether it is run in an SSH-session and put it into their profile?
Is there any workaround to get Powershell as default shell without breaking things like SFTP? All I can see as a solution for now is to prepend every command in our automation scripts at work with powershell.exe. This is not very ideal though. We typically execute single commands in an automated fashion with ssh Administrator@<ip> <command>
What about a flag to indicate whether or not it is an interactive session. For example in linux, I can place a stanza at the top of my .bashrc to drop non interactive sessions out from the remainder of the config
# If not running interactively, don't do anything
# this keeps SCP (file transfer from throwing errors) -- stops here
case $- in
*i*) ;;
*) return;;
esac
Activity
benkevan commentedon Feb 8, 2016
Rather this should be configurable and not statically set. I'd prefer it to be opened in cmd as my profile.ps1 is pretty heavy.
aduzsardi commentedon May 2, 2017
this can be solved by adding
ForceCommand powershell.exein your sshd_config , you can also door
Match Groupfor groupstaynes13 commentedon May 15, 2017
Alexandru Duzsardi (@aduzsardi) using
ForceCommand powershell.exewill help just to interactive session but it breaks things like SFTP. Try to do SFTP connection to server which has ForceCommand enabled, SFTP won't be happy with powershell logo message :-)nkrepo commentedon Jul 21, 2017
Is there workaround for getting sftp work when powershell is the default ssh shell?
bagajjal commentedon Aug 10, 2017
We couldn't find a perfect solution.
Here is our current proposal,
Read the default SSH shell from an user environment variable that has the full path (ex - C:\Windows\System32\cmd.exe)
Check if the default SSH shell is trusted,
a) If the executable is from system32 path (ex - C:\Windows\System32)
(or)
b) If the executable is published from a trusted source (ex - Microsoft).
If step 2 succeeds then launch the default SSH shell.
If step 2 fails then launch the cmd.exe
Issue with this proposal,
If a user has unpublished powershell.exe, step-2 will fail and we end up launching cmd.exe..
We would like to hear from the community, alternative proposals or any suggestions..
lucastheisen commentedon Aug 10, 2017
Anything that can be done to make powershell the default will be good for me, but I wonder how the SSH shell from an user environment variable will get set... I usually set environment variables in my user profile, but the won't get executed until powershell starts...
DarwinJS commentedon Aug 10, 2017
Looks like powershell.exe from powershell core is not signed by Microsoft (at least beta 4), so does that mean it would have to be installed under system32 to work with OpenSSH?
What does "trusted" mean in this context?
In the past Microsoft has considered "Program Files" locations more trustworthy than user writable locations because it takes admin permissions to place something there.
manojampalam commentedon Aug 14, 2017
The intention here is address the security concern around "sshd launching malware injected arbitrary session process". Sticking with cmd.exe keeps it plain simple.
Otherwise we are trying to understand if there are any specific requirements mandating Powershell by default (apart from the convenience aspect). I see a drawback - its difficult to adjust Powershell session prompt (PS:>) to make it identify a remote session (like we do for cmd.exe).
BTW, Powershell could be launched straight away as follows
ssh.exe -t user@target powershell
Scrxtchy commentedon Sep 3, 2017
Manoj Ampalam (@manojampalam) was there an update to support this?


Using this command puts the local terminal in a forever waiting state.
The server then climbs CPU usage
diogocp commentedon Sep 5, 2017
Manoj Ampalam (@manojampalam)
Git server does not work properly if cmd is the default (#752).
manojampalam commentedon Sep 5, 2017
Scratch (@Scrxtchy) please open a new issue for what you are seeing. That's not expected (I don't see it on my end). Fill in the template and we'll take it forward.
Rondom commentedon Sep 5, 2017
Can't you set the COMSPEC variable to powershell.exe and use that? (I admit that I left Windows behind before the switch to NT/XP, so this may be outdated knowledge)
bagajjal commentedon Sep 5, 2017
Andreas Gnau (@Rondom) - Using COMPSPEC variable is not ideal solution.
There can be a situation where the default shell has to be PowerShell for ssh sessions but other applications still needs the default shell as cmd.exe..
As mentioned earlier one of our proposals is to use a new environment variable instead of COMPSPEC.
Also we need to add few security checks when we start using environment variables as any malware can modify the environment variable thus causing a security threat.
Rondom commentedon Sep 16, 2017
If there is such a use case (which one?), wouldn't it be enough to instruct those users to write their own wrapper that checks whether it is run in an SSH-session and put it into their profile?
hsson commentedon Sep 18, 2017
Is there any workaround to get Powershell as default shell without breaking things like SFTP? All I can see as a solution for now is to prepend every command in our automation scripts at work with powershell.exe. This is not very ideal though. We typically execute single commands in an automated fashion with
ssh Administrator@<ip> <command>manojampalam commentedon Sep 19, 2017
Here's one proposal if its OK to change the default shell for all users.

Support a registry entry like this:
erichiller commentedon Sep 19, 2017
What about a flag to indicate whether or not it is an interactive session. For example in linux, I can place a stanza at the top of my
.bashrcto drop non interactive sessions out from the remainder of the config