In order to use public and private key based authentication to SFTP to your server, you need to have SSH enabled on your hosting account. Most hosts do not enable SSH by default, so you might want to check with your host and get it enabled if it isn't already. Once SSH is enabled, connecting to your server is simple. Here are three main steps involved:
Is there some other way to authenticate with only a username or hostname and private key using SSH.NET lib? C#.net ssh private-key ssh.net. Improve this question. Follow edited Nov 21 '18 at 7:15. 145k 38 38 gold badges 328 328 silver badges 688 688 bronze badges. SSH client keys are used to authenticate Jitterbit with external resources such as SFTP servers. This page describes how to use SSL client keys specifically for SFTP connections (used with Cloud Studio FTP endpoints or Design Studio FTP sources/targets), and how to convert keys to an appropriate format for Jitterbit Harmony Private Agents.
- Generating public and private Key pairs using Cpanel.
- Downloading and converting the private key into PPK (PuTTY Private Key) format.
- Connecting to your server using an FTP client and using the PPK key for authentication.
So let's look at these steps in details:
Generating Public and Private Key Pairs Using Cpanel
In order to use SFTP, we first need to generate public and private key pairs. This can easily be done using Cpanel as detailed in the steps below:
Step 1:Login to Your Cpanel and click on SSH Shell Access under the security section.
Step 2: Click on the Manage SSH Keys button and then Click on the Generate a New Key link.
Step 3: On this page, enter the following details:
Key Password: Any password. (Note: This is the passpharse that you will need to enter while you SFTP.)
Key Type: RSA
Key Size: 2048
Once all details are entered, click on Generate Key (refer image above). This will generate a public and private key pair. You should now be able to see these files in your Manage SSH Keys page.
Step 4: On the Manage SSH Keys page, click on Manage Authorization and then click the Authorize button. This will authorize the key for usage as shown in the image below.
Step 5: Click on the View or Download link in the Private Keys section to covert and download your private key.
Converting Private Key to PPK Format
We now need to convert the private key to PPK format. You can do this using the covert key option on Cpanel, or you can download the raw file and covert it to PPK format using PuttyGen. In most cases, the Cpanel convert option works pretty good, so you can stick with it. But in-case, you don't have that option in your Cpanel account, you can use the Puttygen method. Let's look at both these methods:
Option 1: Converting the key to PPK format using Cpanel Covert key option:
Ssh Key Generation
To use this option, enter your passphrase in the space provided and click Convert as shown in the image below. You can then download the converted key to your computer and save it in an accessible location.
Note: The passpharse is the key password that you used while generating the keys in Cpanel.
Option 2: Converting the Key to PPK format Using PuttyGen:
This option involves using PuttyGen to convert the key. If you don't have PuttyGen installed, you can download it free from here. Once downloaded and installed, follow these steps:
Step 1: As shown in the image above (marked Option 2), click on the 'Download Key' button on the View or Download SSH Keys page. This will download the private key (id_rsa) to your computer. Copy and save this file in an accessible location.
Step 2: Open the PuttyGen application and click Run.
Step 3: Go to Conversions > Import Key, browse to the location of your downloaded private key file (id_rsa) and select the file.
Once you load the file you will be prompted to enter the passpharse. Enter the passpharse and click ok.
Step 4: Make sure that the SSH2 RSA option is selected and the number of bits is set to 2048.
Step 5: Click on Save private key and save the file with your preferred name. (Refer image above).
SFTP to the Server
Now that we have our public and private keys setup, we can SFTP to the server. You can do this using any FTP client like Filezilla or WinSCP. I am using WinSCP for this tutorial.
Step 1: Open WinSCP and create a new FTP connected by clicking on New Site and enter the following details:
Host Name: ftp.domainname.com
Port Number: 22
Username: Cpanel Username
Password: Cpanel Password
Step 2: Click on the Advanced botton to open the Advanced Site Settings page as shown in point no.6 in the image above.
Step 3: On the Advanced Site Settings page click on Authentication and then browse to the location of your PPk file. Refer image below:
Step 4: Once done, click ok and then click Save to save the settings.
Step 5: Click Login to login to your server using SFTP. Once the connection is establised and the server has finished verifing the private and public keys, you will be promoted to enter the passpharse. Enter the passpharse and click Ok.
Connect To Sftp With Ssh Key
You should now be connected to your server using SFTP.
Recently, Microsoft has released a port of OpenSSH for Windows. You can use the package to set up an SFTP/SSH server on Windows.
- Installing SFTP/SSH Server
- Connecting to the server
Advertisement

- In Settings app, go to Apps > Apps & features > Manage optional features.
- Locate “OpenSSH server” feature, expand it, and select Install.
Binaries are installed to %WINDIR%System32OpenSSH
. Configuration file (sshd_config
) and host keys are installed to %ProgramData%ssh
(only after the server is started for the first time).
You may still want to use the following manual installation if you want to install a newer version of OpenSSH than the one built into Windows 10.
- Download the latest OpenSSH for Windows binaries (package
OpenSSH-Win64.zip
orOpenSSH-Win32.zip
) - As the Administrator, extract the package to
C:Program FilesOpenSSH
- As the Administrator, install sshd and ssh-agent services:
- Allow incoming connections to SSH server in Windows Firewall:
- When installed as an optional feature, the firewall rule “OpenSSH SSH Server (sshd)” should have been created automatically. If not, proceed to create and enable the rule as follows.
- Either run the following PowerShell command as the Administrator:
ReplaceC:System32OpenSSHsshd.exe
with the actual path to thesshd.exe
(C:Program FilesOpenSSHssh.exe
, had you followed the manual installation instructions above). - or go to Control Panel > System and Security > Windows Defender Firewall1 > Advanced Settings > Inbound Rules and add a new rule for port 22.
- Start the service and/or configure automatic start:
- Go to Control Panel > System and Security > Administrative Tools and open Services. Locate OpenSSH SSH Server service.
- If you want the server to start automatically when your machine is started: Go to Action > Properties. In the Properties dialog, change Startup type to Automatic and confirm.
- Start the OpenSSH SSH Server service by clicking the Start the service.
These instructions are partially based on the official deployment instructions.
Follow a generic guide for Setting up SSH public key authentication in *nix OpenSSH server, with the following difference:
- Create the
.ssh
folder (for theauthorized_keys
file) in your Windows account profile folder (typically inC:Usersusername.ssh
).2 - For permissions to the
.ssh
folder and theauthorized_keys
file, what matters are Windows ACL permissions, not simple *nix permissions. Set the ACL so that the respective Windows account is the owner of the folder and the file and is the only account that has a write access to them. The account that runs OpenSSH SSH Server service (typicallySYSTEM
orsshd
) needs to have read access to the file. - Though, with the default Win32-OpenSSH configuration there is an exception set in
sshd_config
for accounts inAdministrators
group. For these, the server uses a different location for the authorized keys file:%ALLUSERSPROFILE%sshadministrators_authorized_keys
(i.e. typicallyC:ProgramDatasshadministrators_authorized_keys
).
Before the first connection, find out the fingerprint of the server’s host key by using ssh-keygen.exe
for each file.
In Windows command-prompt, use:
Replace %WINDIR%System32
with %ProgramFiles%
, if appropriate.
In PowerShell, use:
Replace $env:WINDIRSystem32
with $env:ProgramFiles
, if appropriate.
You will get an output like this:
Start WinSCP. Login dialog will appear. On the dialog:
- Make sure New site node is selected.
- On New site node, make sure the SFTP protocol is selected.
- Enter your machine/server IP address (or a hostname) into the Host name box.
- Enter your Windows account name to the User name box. It might have to be entered in the format
user@domain
if running on a domain. - For a public key authentication:
- Press the Advanced button to open Advanced site settings dialog and go to SSH > Authentication page.
- In Private key file box select your private key file.
- Submit Advanced site settings dialog with the OK button.
- For a password authentication:
- Enter your Windows account password to the Password box.
- If your Windows account does not have a password, you cannot authenticate with the password authentication (i.e. with an empty password), you need to use the public key authentication.
- Save your site settings using the Save button.
- Login using Login button.
- Verify the host key by comparing fingerprints with those collected before (see above).
Advertisement
If you cannot authenticate to the server and use Windows 10 Developer mode, make sure that your OpenSSH server does not conflict with an internal SSH server used by the Developer mode. You may need to turn off the SSH Server Broker and SSH Server Proxy Windows services. Or run your OpenSSH server on a different port than 22.
- Guide to Installing Secure FTP Server on Windows using IIS;
- Guide to uploading files to SFTP server;
- Guide to automating operations (including upload).
- Windows Firewall on older versions of Windows.Back
- Windows File Explorer does not allow you to create a folder starting with a dot directly. As a workaround, use
.ssh.
, the trailing dot will allow you to bypass the restriction, but will not be included in the name.Back
