Comment on page
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. Key Authentication 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:
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAgkdc1nQnrj2DXUJhTN3F2ohbL46Cdhc26kgkgQpknF UT7edP3H+GHaR9avmHClr03L9ZZy7ERaHf0v7lwjnisnQjzFphrCFcGW5H/aLy9Raz7Lnf4ntNmdRY jHAf1wzT0vUxk/G/kD00xZ1KEJWrzm0ld3JQwHNHN6FcKx6803IXT8DglR7HAAKIyF2az5YGFal5EX AK7PKkf4I6Yl3l7u4zUmzBWbtruXWdnbj6qk6qMhN5rPPQIjrbPluziMyLBDfbKln2uzo7rpX/YHE3 PZLOlUWhBRdNHJl2zk9fnxm8TNW8gd45bzuRnXELBJJsfqclLcQMuxxOcMPYheyR1Q== rsa-key-2 0200410How-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: SHA256:n8mulp5MG3dAfNEvUPRWG0UaTIs6JK56Lo+dLWpm0uo [email protected] The key's randomart image is: +---[RSA 2048]----+ | .*=o=| | . .oo=+| | . + o.ooo| | . + o ...| | S + . | | . o = | | . . o.* . | | . *+o=o* . | | .E*+*=+B.. | +----[SHA256]-----+
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 1. Open PuttyGen.exe from the Start Menu.
2. Enter "2048" in the field at the bottom for the number of bits
3. Select the type "RSA" if it is not selected already.
4. Click the Generate button and move your mouse around when prompted to. 5. Select the generated text and right click to copy it to your clipboard. 6. Open Notepad.exe from the Start Menu.
- 7.Paste the key into the blank area.
- 8.Click File > Save as...
- 1.Name this file anything you like as long as it ends in .pub
- 9.Now, click Save Public Key and follow the prompts to save the file.
- 10.Click Save Private Key and follow the prompts to save the file as before.
- 11.Connect via SFTP with Password Authentication.
- 12.Upload the file authorized_keys.pub into the .ssh directory.
- 13.Close the connection.
If unable to upload the public key file, ensure...
- You are logged in via SFTP on port 22. It's not designed to work through FTP(S) or the web interface for security.
- The public key file you upload should be in OpenSSH format and not PuTTY format.
- To check you can open the public key file up in a text editor.
In PuTTY format the first line will look like this:
---- BEGIN SSH2 PUBLIC KEY ----
In OpenSSH format everything is on line 1 and it begins like this:
The following command will convert a PuTTY key to OpenSSH:
$ ssh-keygen -i -f sftp_putty.pub > sftp_openssh.pub