Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Change Default SFTP location in Open SSSH windows #730

Closed
karthick1409 opened this issue May 23, 2017 · 19 comments
Closed

How to Change Default SFTP location in Open SSSH windows #730

karthick1409 opened this issue May 23, 2017 · 19 comments

Comments

@karthick1409
Copy link

karthick1409 commented May 23, 2017

i have installed "OpenSSH for Windows" version for configuring SFTP in windows server 2012. i can able to connect using sftp connection. But by default i am getting user home directory like c:\user\username. But i need one common directory as default location.

@bagajjal
Copy link
Collaborator

In unix world this is accomplished with the "ChrootDirectory". ChrootDirectory is not yet supported in windows...

Its a duplicate of
#539

@karthick1409
Copy link
Author

Is there any other way to achieve this

@bagajjal
Copy link
Collaborator

As far as I know, we don't have..

@gregmich29
Copy link

You can try to edit sshd_config, then locate the line where sftp-server is call and add command line argument to the exe --> sftp-server.exe -C C:\MyDirectory
It works fine for me.

@karthick1409
Copy link
Author

karthick1409 commented Oct 19, 2017 via email

@robatilho
Copy link

robatilho commented Feb 17, 2018

@karthick1409 you can try sftp sftp-server.exe -d C:\FTP\

@rxarun
Copy link

rxarun commented Nov 28, 2018

@karthick1409 you can try sftp sftp-server.exe -d C:\FTP\

I have also found this to be working

@vaibhavkadam1987
Copy link

How to chnage the long path(having space in path).i.e D:\FTP Sites\SFTP

@vaibhavkadam1987
Copy link

Any help

@rxarun
Copy link

rxarun commented Dec 11, 2018

Did you try using double quotes?

@manojampalam
Copy link
Contributor

see #784

the last response has a workaround for your problem.

@arreisGit
Copy link

Reading the sftp-server man , and just like it was already mentioned -d should work.

"-d start_directory
specifies an alternate starting directory for users. The pathname may contain the following tokens that are expanded at runtime: %% is replaced by a literal '%', %d is replaced by the home directory of the user being authenticated, and %u is replaced by the username of that user. The default is to use the user's home directory. This option is useful in conjunction with the sshd_config(5) ChrootDirectory option." -- https://www.mankier.com/8/sftp-server

This worked for me:

sftp sftp-server.exe -d "D:\someFolder\anotherFolder"

@yousiftech
Copy link

Dear all,

I have seam issue when I log in on OpenSSH server I can see all root directory, kindly I need to make specific root for this server

@lukaszbachman
Copy link

For all users who had a problem with this solution not working, please note that you may need to edit this file:

C:\ProgramData\ssh\sshd_config

Previously I was making changes to configuration stored in Program Files which was wrong and as a result it didn't make a difference. Changing this file worked for me.

@femston
Copy link

femston commented Aug 19, 2021

Somebody assist me. I have tried all the solutions provided on this trend. my question is should i remove the Subsystem

here is my config :

override default of no subsystems

Subsystem sftp sftp-server.exe -d "C:\SFTPRecording"

Example of overriding settings on a per-user basis

#Match User anoncvs

AllowTcpForwarding no

PermitTTY no

ForceCommand cvs server

ForceCommand internal-sftp

Match User RecUser1
ChrootDirectory "C:\SFTPRecording"

Match Group administrators
AuthorizedKeysFile PROGRAMDATA/ssh/administrators_authorized_keys

@femston
Copy link

femston commented Aug 19, 2021

Reading the sftp-server man , and just like it was already mentioned -d should work.

"-d start_directory
specifies an alternate starting directory for users. The pathname may contain the following tokens that are expanded at runtime: %% is replaced by a literal '%', %d is replaced by the home directory of the user being authenticated, and %u is replaced by the username of that user. The default is to use the user's home directory. This option is useful in conjunction with the sshd_config(5) ChrootDirectory option." -- https://www.mankier.com/8/sftp-server

This worked for me:

sftp sftp-server.exe -d "D:\someFolder\anotherFolder"

@arreisGit
on my config file in openssh version 8.6.0 , i can see Subsystem sftp sftp-server.exe
is this the right one

@wan-liyang
Copy link

Somebody assist me. I have tried all the solutions provided on this trend. my question is should i remove the Subsystem

here is my config :

override default of no subsystems

Subsystem sftp sftp-server.exe -d "C:\SFTPRecording"

Example of overriding settings on a per-user basis

#Match User anoncvs

AllowTcpForwarding no

PermitTTY no

ForceCommand cvs server

ForceCommand internal-sftp

Match User RecUser1 ChrootDirectory "C:\SFTPRecording"

Match Group administrators AuthorizedKeysFile PROGRAMDATA/ssh/administrators_authorized_keys

added below into C:\ProgramData\ssh\sshd_config work for me, the only thing is need restart service "OpenSSH SSH Server"

Match User sftpuser
ChrootDirectory "C:\SFTP\sftpuser"

@jacquesrici
Copy link

On Windows work for me like this:

Subsystem sftp sftp-server.exe -d /C:/SFTPRecording

@narjonas
Copy link

I only changed the C:\ProgramData\ssh\sshd_config file:

Changing the line: ChrootDirectory "C:\Mydirectory"

and restarting the service in PowerShell with "Restart-Service sshd"

Worked perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests