git-ftp icon indicating copy to clipboard operation
git-ftp copied to clipboard

SFTP access

Open lastlink opened this issue 8 years ago • 4 comments

It's not well documented how to use an ssh key for sftp or if it's even supported. It would be nice to know the commands. Like if git ftp init -u <user> --sftp-key ~/.ssh/id_rsa sftp://YOUR-FTP-SERVER-ADDRESS/app-root/data/html/<foldertouploadto> would work for initializing ftp access using an sftp key.

lastlink avatar May 14 '17 02:05 lastlink

In the documentation, there is an option for --key. This is used to specify the path to the private key. I'm not 100% about this, but you may need to pass the --insecure option with it to use the private key without the public key. So your example could look like this

git ftp init --insecure --key ~/.ssh/id_rsa sftp://user@YOUR-FTP-SERVER-ADDRESS:/app-root/data/html/<foldertouploadto>

adrum avatar May 14 '17 21:05 adrum

Hi @lastlink,

Your are right, there is no proper documentation how to use SFTP with keys. And the behaviour of Git-ftp has been really confusing as well. I can give you some answers, but not all.

If you have a public/private key pair generated by ssh-keygen, you can upload via SFTP like this:

git ftp init -u "$USER" --key "$HOME/.ssh/id_rsa" "sftp://example.com/absolute/path/to/destination"
# or
git ftp init -u "$USER" --key "$HOME/.ssh/id_rsa" "sftp://example.com/~/path/in/home/directory"

There have been a lot of reports that the --insecure flag is needed. It skips verifying the server's identity. I was able to connect to a server without that. It may depend on the server and your operating system.

It would be great to get some reports from OSX and Windows users as well. And we should document this properly.

mkllnk avatar Jun 12 '17 23:06 mkllnk

In my experience, you need the --insecure flag if you omit the public key. Below is an example of how I've used it on a Mac

git ftp push --auto-init --insecure -u "$USER" --key "$HOME/.ssh/id_rsa" --syncroot "path/in/local/dir" "sftp://example.com:~/path/to/remote/dir"

adrum avatar Jun 13 '17 13:06 adrum

What do you think about pull #361?

mkllnk avatar Jun 14 '17 09:06 mkllnk