Copy files to your site using SFTP

Mindspun hosting does not allow FTP access to your site but instead uses the far more secure SFTP. Note: not FTPS. The SFTP service listens on the non-standard port 2022.

Depending upon your OS, there are numerous clients available, but for the for this How-To we’ll use the command-line version where the commands are nearly the same regardless of the operating system.

Authentication

Authentication is tied to the users on your site. Only administrators are allowed to SFTP into the box.

  • Username: <user_login>_<site_id>
  • Password: <user_pass>
  • Port: 2022

Where <user_login> is an administrator login on your WordPress site and <user_pass> is the password for that administrator login.

For example, if your user_login is ‘admin’ and your site ID is 63b83d65aff08edf, then your username would be admin_63b83d65aff08edf.

Using sftp

A typical connection looks like the following, assuming the above credentials.

$ sftp -P 2022 [email protected]
[email protected]'s password: 
Connected to wp-63b83d65aff08edf.mindspun.site.
sftp> \quit

You may use any hostname to your site.

The sftp command takes you to the wp-content folder of your site and from there you can modify any files you choose.

Using sshpass

It’s tedious to type in your password each time so an alternative is to use sshpass. Care must be taken with this approach since it stores you password in a file on your local system.

Create a file that contains your password in a known location such as

~/.sshpass/wp-63b83d65aff08edf.mindspun.site

Then use the command:

sshpass -f ~/.sshpass/wp-63b83d65aff08edf.mindspun.site sftp -P 2022 [email protected]

Be careful to protect your credentials with this approach!

rclone

If you’re working on a theme or plugin, one of the most common tasks is copying a directory and its contents to your server. The rclone command is perfect for this task.

Create a remote

A ‘remote’ in rclone is a server definition and how to connect to it. You specify information about how to connect to the server and what credentials to use, then you can reference the remote by a human-friendly name.

$ rclone config
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n

Enter name for new remote.
name> mindspun

Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
Storage> sftp

Option host.
SSH host to connect to.
E.g. "example.com".
Enter a value.
host> wp-63b83d65aff08edf.mindspun.site

Option user.
SSH username.
Enter a string value. Press Enter for the default (matt).
user> admin_63b83d65aff08edf                               

Option port.
SSH port number.
Enter a signed integer. Press Enter for the default (22).
port> 2022

Option pass.
SSH password, leave blank to use ssh-agent.
Choose an alternative below. Press Enter for the default (n).
y) Yes, type in my own password
g) Generate random password
n) No, leave this optional password blank (default)
y/g/n> y
Enter the password:
password:
Confirm the password:
password:

...

Configuration complete.
Options:
- type: sftp
- host: wp-63b83d65aff08edf.mindspun.site
- user: admin_63b83d65aff08edf
- port: 2022
- pass: *** ENCRYPTED ***
Keep this "mindspun" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y

Current remotes:

Name                 Type
====                 ====
mindspun             sftp

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q

The rclone edit command prompts for several more options after the password, just hit return to select the defaults. Onse the configuration is define, you can refer to it by the remote simple remote name you chose ‘mindspun’.

Copying a directory

The rclone ‘sync’ command copies a file or directory.

Say you are in the top-level directory of a theme mytheme on your local machine and you want to update that theme on your server, you can do so like:

rclone sync . mindspun:themes/mytheme/

This command assumes that mytheme exists on the server already and just needs to be updated to the most recent version.