@@ -70,51 +70,66 @@ remote computer. And, you must enable **password** or **key-based** authenticati
7070
71711 . Edit the ` sshd_config ` file located at ` $Env:ProgramData\ssh ` .
7272
73- Make sure password authentication is enabled:
73+ - Make sure password authentication is enabled:
7474
75- ```
76- PasswordAuthentication yes
77- ```
75+ ```
76+ PasswordAuthentication yes
77+ ```
7878
79- Create the SSH subsystem that hosts a PowerShell process on the remote computer:
79+ - Create the SSH subsystem that hosts a PowerShell process on the remote computer:
8080
81- ```
82- Subsystem powershell C:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo
83- ```
81+ ```
82+ Subsystem powershell C:/progra~1/powershell/7/pwsh.exe -sshs
83+ ```
8484
85- > [ !NOTE]
86- > Starting in PowerShell 7.4, you no longer need to use the ` -NoLogo ` parameter when running
87- > PowerShell in SSH server mode.
85+ > [!NOTE]
86+ > There is a bug in OpenSSH for Windows that prevents you from using a path with spaces for the
87+ > subsystem executable. There are two ways to work around this issue:
88+ >
89+ > - Use the Windows _8.3-style_ short name for the PowerShell executable path
90+ > - Create a symbolic link to the PowerShell executable that results in a path without spaces
91+ >
92+ > For more information, see [issue #784][09] in the PowerShell/Win32-OpenSSH repository.
8893
89- > [ !NOTE]
90- > The default location of the PowerShell executable is ` C:/progra~1/powershell/7/pwsh.exe ` . The
91- > location can vary depending on how you installed PowerShell.
92- >
93- > You must use the 8.3 short name for any file paths that contain spaces. There's a bug in
94- > OpenSSH for Windows that prevents spaces from working in subsystem executable paths. For more
95- > information, see this [ GitHub issue] [ 09 ] .
96- >
97- > The 8.3 short name for the ` Program Files ` folder in Windows is usually ` Progra~1 ` . However,
98- > you can use the following command to make sure:
99- >
100- > ``` powershell
101- > Get-CimInstance Win32_Directory -Filter 'Name="C:\\Program Files"' |
102- > Select-Object EightDotThreeFileName
103- > ```
104- >
105- > ```Output
106- > EightDotThreeFileName
107- > ---------------------
108- > C:\progra~1
109- > ```
110-
111- Optionally, enable key authentication:
94+ You only need to get the 8.3-style name for the segment of the path that contains the space. By
95+ default PowerShell 7 is installed in `C:\Program Files\PowerShell\7\`. The 8.3-style name for
96+ `Program Files` should be `progra~1`. You can use the following command to verify the name:
11297
113- ```
114- PubkeyAuthentication yes
115- ```
98+ ```powershell
99+ Get-CimInstance Win32_Directory -Filter 'Name="C:\\Program Files"' |
100+ Select-Object EightDotThreeFileName
101+ ```
102+
103+ The 8.3 name is a legacy feature of the NTFS file system that can be disabled. This feature
104+ must be enabled for the volume on which PowerShell is installed.
116105
117- For more information, see [Managing OpenSSH Keys][05].
106+ Alternatively, you can create a symbolic link to the PowerShell executable that results in a
107+ path without spaces. This method is preferred because it allows you to update the link if the
108+ path to the PowerShell executable ever changes, without also needing to update your
109+ `sshd_config` file.
110+
111+ Use the following command to create a symbolic link to the executable:
112+
113+ ```powershell
114+ $newItemSplat = @{
115+ ItemType = 'SymbolicLink'
116+ Path = 'C:\ProgramData\ssh\'
117+ Name = 'pwsh.exe'
118+ Value = (Get-Command pwsh.exe).Source
119+ }
120+ New-Item @newItemSplat
121+ ```
122+
123+ This command creates the symbolic link in the same directory used by the OpenSSH server to store
124+ the host keys and other configuration.
125+
126+ - Optionally, enable key authentication:
127+
128+ ```
129+ PubkeyAuthentication yes
130+ ```
131+
132+ For more information, see [Managing OpenSSH Keys][05].
118133
1191341. Restart the **sshd** service.
120135
@@ -137,34 +152,29 @@ remote computer. And, you must enable **password** or **key-based** authenticati
137152
1381531 . Edit the ` sshd_config ` file at location ` /etc/ssh ` .
139154
140- Make sure password authentication is enabled:
155+ - Make sure password authentication is enabled:
141156
142- ```
143- PasswordAuthentication yes
144- ```
157+ ```
158+ PasswordAuthentication yes
159+ ```
145160
146- Optionally, enable key authentication:
161+ - Optionally, enable key authentication:
147162
148- ```
149- PubkeyAuthentication yes
150- ```
163+ ```
164+ PubkeyAuthentication yes
165+ ```
151166
152- For more information about creating SSH keys on Ubuntu, see the manpage for
153- [ ssh-keygen] [ 08 ] .
167+ For more information about creating SSH keys on Ubuntu, see the manpage for [ssh-keygen][08].
154168
155- Add a PowerShell subsystem entry:
156-
157- ```
158- Subsystem powershell /usr/bin/pwsh -sshs -NoLogo
159- ```
169+ - Add a PowerShell subsystem entry:
160170
161- > [ !NOTE ]
162- > The default location of the PowerShell executable is ` /usr/bin/pwsh ` . The location can vary
163- > depending on how you installed PowerShell.
171+ ```
172+ Subsystem powershell /usr/bin/pwsh -sshs -NoLogo
173+ ```
164174
165- > [ !NOTE]
166- > Starting in PowerShell 7.4, you no longer need to use the ` -NoLogo ` parameter when running
167- > PowerShell in SSH server mode .
175+ > [!NOTE]
176+ > The default location of the PowerShell executable is `/usr/bin/pwsh`. The location can vary
177+ > depending on how you installed PowerShell .
168178
1691791. Restart the **ssh** service.
170180
@@ -193,31 +203,27 @@ remote computer. And, you must enable **password** or **key-based** authenticati
193203 sudo nano /private/etc/ssh/sshd_config
194204 ```
195205
196- Make sure password authentication is enabled:
197-
198- ```
199- PasswordAuthentication yes
200- ```
206+ - Make sure password authentication is enabled:
201207
202- Add a PowerShell subsystem entry:
208+ ```
209+ PasswordAuthentication yes
210+ ```
203211
204- ```
205- Subsystem powershell /usr/local/bin/pwsh -sshs -NoLogo
206- ```
212+ - Add a PowerShell subsystem entry:
207213
208- > [ !NOTE ]
209- > The default location of the PowerShell executable is ` /usr/local/bin/pwsh ` . The location can
210- > vary depending on how you installed PowerShell.
214+ ```
215+ Subsystem powershell /usr/local/bin/pwsh -sshs -NoLogo
216+ ```
211217
212- > [ !NOTE]
213- > Starting in PowerShell 7.4, you no longer need to use the ` -NoLogo ` parameter when running
214- > PowerShell in SSH server mode .
218+ > [!NOTE]
219+ > The default location of the PowerShell executable is `/usr/local/bin/pwsh`. The location can
220+ > vary depending on how you installed PowerShell .
215221
216- Optionally, enable key authentication:
222+ - Optionally, enable key authentication:
217223
218- ```
219- PubkeyAuthentication yes
220- ```
224+ ```
225+ PubkeyAuthentication yes
226+ ```
221227
2222281. Restart the **sshd** service.
223229
0 commit comments