3

I've setup the built-in OpenSSH in Windows 10 and connected remotely via WinSCP SFTP protocol. I seem to have access to all folders in my C: drive, but I cannot access the external drives of my computer. Going to the "root" folder just lists the C: drive. I tried creating a soft directory symlinks in a directory that I can access, but that doesn't seem to work. They appear as files in WinSCP and I cannot access them. How can I add them? Also, is there a way to restrict access to certain folders if I wanted to share access to only certain folders of my server?

4 Answers 4

1

While some Windows SFTP servers do implement a virtual root folder which lists available drives, Win32-OpenSSH does not. It redirects the root folder / to /C:/ (or maybe to a system drive).

If you want to visit another drive, you have to manually change a working directory.

  • In WinSCP GUI, you can do that using "Open Directory" command and typing a path to the desired drive, like /D:/.

  • In command-line SFTP clients, like OpenSSH sftp, PuTTY psftp or WinSCP scripting, you can use cd command, like:

    cd /D:/
    

There's actually WinSCP FAQ for How do I change drive on the remote panel?


Regarding your attempt to solve this using a symlink: A symlink really shows as a file in WinSCP (as the server presents it as an unknown file type). But a directory junction shows as a directory (the server presents it as a regular directory, not a link). Though since WinSCP 5.14.2, you can make WinSCP try to enter "file" using Ctrl+PgDn.

0
0

On server machine, change default command shell as "PowerShell".

New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force

Refer this link This change should solve your problem.

1
  • How does changing the default shell enable adding/removing drives to the OpenSSH SFTP server. I don't get it.
    – zx485
    Commented Jul 13, 2020 at 17:27
0

used this to set up sftp https://v2cloud.com/tutorials/how-to-set-up-an-sftp-server-in-windows

the \ is used by windows, and / is used by unix/linux...  when you configure ssh or sftp it provides a unix/linux like interface, probably if we go through the logs you will see an error for c:, but since it is windows default it sent you to c:\sftproot.... simply set ChrootDirectory D:/SFTPRoot in the sshd_config file

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jan 31, 2023 at 17:12
-1

There seems to be a bug/glitch when using openssh with the default "cmd.exe" shell. At least on my system, when you change the drive letter from c: to d: the dir listing doesn't refresh, even if you do cls first. But with powershell, if you do cls in between, then it works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .