Using SSH keys with SFTP
This is the default authentication method. When connecting via SFTP, if key authentication is not set up the user will be prompted for a password.
If you wish to use publickey authentication, upload your public key(s) into the .ssh folder using SFTP with Password Authentication.
The format supported is the OpenSSH format, which is typically a file named "id_rsa.pub" or similar. Within the file you will find a single line such as:
How-to Generate a Key Pair on macOS or Linux using OpenSSH
- Open the Terminal and run the following commands:
$ cd ~/.ssh
$ ssh-keygen -f sftp
- You should get the following response:
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in sftp.
Your public key has been saved in sftp.pub.
The key fingerprint is:
The key's randomart image is:
| . .oo=+|
| . + o.ooo|
| . + o ...|
| S + . |
| . o = |
| . . o.* . |
| . *+o=o* . |
| .E*+*=+B.. |
- This file should be uploaded into the .ssh folder using SFTP with Password Authentication.
The sftp file should be used by the SFTP client to connect.
How-to Generate a Key Pair on Windows using PuTTY
- Open PuttyGen.exe from the Start Menu.
- Enter "2048" in the field at the bottom for the number of bits,
- Select the type "RSA" if it is not selected already.
- Click the Generate button and move your mouse around when prompted to.
- Select the generated text and right click to copy it to your clipboard.
- Open Notepad.exe from the Start Menu.
- Paste the key into the blank area.
- Click File > Save as...
- Name this file anything you like as long as it ends in .pub
- Now, click Save Public Key and follow the prompts to save the file.
- Click Save Private Key and follow the prompts to save the file as before.
- Connect via SFTP with Password Authentication.
- Upload the file authorized_keys.pub into the .ssh directory.
put authorized_keys.pub /.ssh/authorized_keys.pub
- Close the connection.
Examples of Usage
FileZilla (recommended, multi-platform)
psftp -i .ssh/sftp.ppk username@YourCompanySiteAddress.com
WS_FTP Pro (Windows)
Command Line Interface (BSD)
$ sftp -i ~/.ssh/sftp username@YourCompanySiteAddress.com