Help

Working with a Server via SFTP (SSH File Transfer Protocol)

SFTP (SSH File Transfer Protocol) is a secure protocol for managing files on a remote server. It lets you transfer files, create directories, manage access permissions, and much more. For the user, working with SFTP is very similar to working with FTP, but the connection is made over the secure SSH protocol.

To connect via SFTP, you can use an FTP client such as FileZilla.

Connection details

The following details are usually used to connect via SFTP:

  • Host: your server's IP address (you can find it on the server's main page in the control panel).
  • Username: the name of a user created on the server.
  • Password: that user's password.
  • Port: 22.

If you use RSA key authentication, you will also need to enter the passphrase (if one was set when the key was created) and load the public key.

We strongly recommend not connecting via SFTP as the root user. It is not only insecure but also inconvenient. If you log in as root, you will land in root's home directory (usually /root) and will have to navigate the file structure to reach your project directory. In addition, files you upload as root will belong to the root:root user and group, and the web server will not be able to read them. This can cause file access errors on your site.

Fastpanel

If you use Fastpanel, the fastuser user is created during installation. To connect as this user, use the following details:

  • Host: your server's IP address.
  • Username: fastuser.
  • Password: the password set for the fastuser user (note that it is different from the root password).
  • Port: 22.

Once connected, you will be in the /var/www/fastuser/data directory.

Sites are usually located in subfolders of this directory: /var/www/fastuser/data/www/domain_name.

If you have created an additional user (for example, user), use that user's details to connect.

  • Host: the server's IP address
  • Username: user
  • Password: the password of the user user
  • Port: 22

Once connected, you will be in the /var/www/user/data directory.

Site directories are located at: /var/www/user/data/www/domain_name.

VestaCP

By default, VestaCP has an admin user. To connect as this user, use the following details:

  • Host: the server's IP address
  • Username: admin
  • Password: the admin user's password (the same as the root password by default)
  • Port: 22

Once connected, you will be in the /home/admin/ directory.

Site directories are located at: /home/admin/web/domain_name.

If you have created an additional user in VestaCP (for example, user) and added a site under that user in the WEB section, use the following details to connect via SFTP:

  • Host: the server's IP address
  • Username: user
  • Password: the password of the user user
  • Port: 22

Once connected, you will be in the /home/user/ directory.

Site directories are located at: /home/user/web/domain_name.

ISPmanager

Before connecting via SFTP, make sure the user has shell access. You can check this in ISPmanager: go to Accounts - Users, select the user, and click Edit.

Make sure the Shell access option is checked.

By default, ISPmanager has a www-root user. If you placed sites under this user in the "WWW domains" section, use the following details to connect via SFTP:

  • Host: the server's IP address
  • Username: www-root
  • Password: the www-root user's password (the same as the root password by default)
  • Port: 22

Once connected, you will be in the /var/www/www-root/data/ directory.

Site directories are located at: /var/www/www-root/data/www/domain_name.

If you have created an additional user (for example, user) and added sites under that user, use the following details to connect:

  • Host: the server's IP address
  • Username: user
  • Password: the password of the user user
  • Port: 22

Once connected, you will be in the /var/www/user/data directory.

Site directories are located at: /var/www/user/data/www/domain_name.

Bitrix 7

By default, Bitrix 7 has a bitrix user. To connect via SFTP, use the following details:

  • Host: the server's IP address
  • Username: bitrix
  • Password: the bitrix user's password (the same as the root password by default)
  • Port: 22

Once connected, you will be in the /home/bitrix/ directory.

Site directories are located at: /home/bitrix/www/ (for the main site) and /home/bitrix/ext_www/domain_name (for additional sites created with BitrixVM).

LAMP

By default, this stack runs the web servers as the www-data user. If you want to work as a different user, including connecting via SFTP, make the following changes.

First, connect to the server via SSH and do the following:

  1. Create a new SFTP user (sftpuser in this example) with the home directory /var/www/:
useradd -d /var/www/ sftpuser
  1. Set a password for the new user:
passwd sftpuser

When prompted, enter the password. Note that the characters will not be displayed on the screen as you type.

  1. Add the user to the www-data group:
usermod -aG www-data sftpuser

Make www-data the user's primary group:

usermod -g www-data sftpuser
  1. Open the Nginx configuration file:
nano /etc/nginx/nginx.conf

Open the nginx.conf file in a text editor:

nano /etc/nginx/nginx.conf

Find the line:

user www-data;

And replace it with:

user sftpuser;

Save the changes and close the editor.

To apply the changes, restart Nginx:

service nginx restart

Now check which user the Nginx web server is running as with the command:

ps auxwwww | grep nginx

You will see that the web server is running as the sftpuser user.

  1. For the Apache2 web server, the user is set in one of the following files:

On Ubuntu / Debian:

/etc/apache2/apache2.conf

# Or:

/etc/apache2/envvars

On CentOS:

/etc/httpd/httpd.conf

# Or:

/etc/httpd/envvars

In our LAMP stack, you need to set the variables in the /etc/apache2/envvars file.

To find out which configuration file specifies the www-data user, you can check each of them for this line. Once you find the file containing www-data, replace that value with sftpuser.

Open the Apache2 server variables file:

On Ubuntu / Debian:

nano /etc/apache2/envvars

On CentOS:

nano /etc/httpd/envvars

Find the line:

export APACHE_RUN_USER=www-data

And replace it with:

export APACHE_RUN_USER=sftpuser

Save the changes and close the file.

Then restart the web server. On Debian/Ubuntu, run:

service apache2 restart

On CentOS, use:

service httpd restart

Check which user Apache2 is running as with the command:

ps auxwwww | grep apache
  1. Set the correct permissions, owner, and group for the directory where the sites will be stored (the user's home directory). Run the following commands one by one:
find /var/www -type d -exec chmod 755 {} \;
find /var/www -type f -exec chmod 644 {} \;
chown -R sftpuser:www-data /var/www/

The setup is complete.

Now test the SFTP connection using the following login details:

  • Host: the server's IP address
  • Username: sftpuser
  • Password: the sftpuser user's password (set in step 2)
  • Port: 22

Have more questions about Hosting?