Links
Comment on page

Using SSH keys with SFTP

Password Authentication
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 0200410 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: 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.
  1. 7.
    Paste the key into the blank area.
  2. 8.
    Click File > Save as...
    1. 1.
      Name this file anything you like as long as it ends in .pub
  3. 9.
    Now, click Save Public Key and follow the prompts to save the file.
  4. 10.
    Click Save Private Key and follow the prompts to save the file as before.
  5. 11.
    Connect via SFTP with Password Authentication.
  6. 12.
    Upload the file authorized_keys.pub into the .ssh directory.
  7. 13.
    Close the connection.
Troubleshooting Setup
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 SFTP credentials match the user to whom the SSH key belongs. The /.ssh folder is private and unique to each user, so even an admin cannot access it without changing the user's password.
  • 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: ssh-rsa AA
The following command will convert a PuTTY key to OpenSSH:
$ ssh-keygen -i -f sftp_putty.pub > sftp_openssh.pub
©2023 Orange Platform LLC dba SmartFile. All rights reserved.