How to choose an SFTP connection type

Introduction

SFTP is a file transfer protocol similar to FTP but it uses SSH as the network protocol (and benefits from leaving SSH to handle the authentication and encryption.) SCP is only for transferring files, and can't do other things like list remote directories or removing files, which SFTP does do.

Prerequisites

SSH: Password

Your SSH server requires a username and password.

SSH: Public Key File

You need to create a key pair; a public key and a private key.

Your client server must have the keys id_rsa and id_rsa.pub.

The keys files must be owned by the web server (e.g. "apache") so it can read them (they should be CHMOD 0600.)

If they are owned by another user, they must be CHMOD 0644, or they can be CHMOD 0640 if they have the web server as the group.

The remote server needs a file at /.ssh/authorized_keys that will contain the content of your id_rsa.pub file.

The private key can optionally be password protected.

SSH: Agent

Your SSH server uses an agent on the web server to authenticate, without a password.