How to add/remove drives to Windows OpenSSH SFTP server?

7,112

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.

Share:
7,112

Related videos on Youtube

Mike
Author by

Mike

Updated on September 18, 2022

Comments

  • Mike
    Mike over 1 year

    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?

  • Erik
    Erik almost 5 years
    I have tried to create such a junction using the mklink command in Windows, like this: mklink /D C:\D D:\. However, when I do so, I cannot copy any files to subfolders in /D, it says "access denied" in WinSCP, although when I map the D-rive directly as ChrootDirectory, this works. So by linking, I lose some file permissions, can I set them directly anyhow?
  • Martin Prikryl
    Martin Prikryl almost 5 years
    /D does not create a junction. It creates a folder symbolic link. Junction is created by /J. Though I actually cannot reproduce the problem with symlink (I have described in my answer) anymore. For me even symbolic link works. Maybe they have fixed it meanwhile. Anyway, try /J.
  • Erik
    Erik almost 5 years
    It looks like this doesn't work as well for me, it also says in the permissions rwx------. And another thing I noticed is that it tries to create the file as myfile.txt..filepart, which works, so I have that file with size 0, so maybe some renaming process fails? Looks really strange to me, all I can say that the behaviour is similar in WinSCP as in Filezilla, so I guess I need to set some permissions on serverside, but where is the right place to look?
  • Martin Prikryl
    Martin Prikryl almost 5 years
    Windows OpenSSH server follows permissions of your Windows account. There's nothing to be set specifically for the SFTP/SSH server. The permissions you see in WinSCP are not really relevant. There's no way the server can map complex Windows ACL to simple *nix-style permissions that you see in WinSCP. -- If you login with an SSH terminal client, can you create files on the junction/symlink?
  • Erik
    Erik almost 5 years
    Martin, thanks for your reply, it works when I copy the files using putty and an open SSH-connection. Also see my other comment how to reproduce the steps using Filezilla (WinSCP will behave like FIlezilla there)
  • zx485
    zx485 almost 4 years
    How does changing the default shell enable adding/removing drives to the OpenSSH SFTP server. I don't get it.