Changing Default directory on SFTP login

November 1, 2015 1.3k views
LEMP Getting Started Configuration Management

Whenever I SFTP login using FileZilla, It opens up/home/MYUSERACCOUNT
I would want to open the folder usr/share/nginx/html/ by default when I login.
(usr/share/nginx/html/ is the default directory where .html files are stored for my website)
Is there a way to do so?
Thanks :)

2 Answers

You can set the default remote directory in FileZilla and FileZilla will cd in that directory when you connect to the site. To do this, you need to go to FileZilla's Site manager and add or click on the site. Then click on the Advanced tab and you will see a field named "Default remote directory". You can enter /usr/share/nginx/html/ and click ok to save it. Now when you connect to the site, it will automatically cd into /usr/share/nginx/html/. :)

@prashantsani - Alternatively, you could simply modify the home directory for your user. You'll need to login to the CLI as root and issue the following command:

usermod -d /usr/share/nginx/html/ username

Broken down:

usermod is the user modification command

-d is the directory to set as the new home for username

... where username is the name of the user you're logging in as. This effectively removes /home/username/ as the home directory and replaces it with the one you specify above which, in this case, will be /usr/share/nginx/html/.

Have another answer? Share your knowledge.