Set up SSH public key authentication :: WinSCP (2024)

Documentation » Using WinSCP » Guides » Set Up »

This guide contains a description of setting up public key authentication for use with WinSCP. You may want to learn more about public key authentication or SSH keys instead.

  • Before Starting
  • Generate Key Pair
  • Configure Server to Accept Public Key
    • OpenSSH
    • OpenSSH on Windows
    • ssh.com
    • Other SSH Servers
  • Configure WinSCP Session
  • Public Key Authentication in Clouds
  • Further Reading

Advertisem*nt

Before Starting

Before starting you should:

Generate Key Pair

If you do not have a key pair yet, start with generating new key pair.

Configure Server to Accept Public Key

Connect to your SSH server using WinSCP with the SSH protocol, using other means of authentication than public key, e.g. typically using password authentication.

Once logged in, configure your server to accept your public key. That varies with SSH server software being used. The most common SSH server is OpenSSH.

OpenSSH

You can use Session (Tabs) > Install Public Key into Server command on the main window, or Tools > Install Public Key into Server command on SSH > Authentication page page on Advanced Site Settings dialog. The functionality of the command is similar to that of OpenSSH ssh-copy-id command.

Or you can configure the key manually:

  • Navigate into a .ssh subdirectory of your account home directory. You may need to enable showing hidden files to see the directory. If the directory does not exist, you need to create it first.
  • Once there, open a file authorized_keys for editing. Again you may have to create this file, if this is your first key.
  • Switch to the PuTTYgen window, select all of the text in the Public key for pasting into OpenSSH authorized_keys file box, and copy it to the clipboard (Ctrl+C). Then, switch back to the editor and insert the data into the open file, making sure it ends up all on one line. Save the file. WinSCP can show you the public key too.
  • Ensure that your account home directory, your .ssh directory and file authorized_keys are not group-writable or world-writable. Recommended permissions for .ssh directory are 700. Recommended permissions for authorized_keys files are 600. Read more about changing permissions.

Advertisem*nt

OpenSSH on Windows

There are some specifics when setting up the public key authentication on OpenSSH server on Windows.

ssh.com

  • Save a public key file from PuTTYgen, and copy that into the .ssh2 subdirectory of your account home directory.
  • In the same subdirectory, edit (or create) a file called authorization. In this file you should put a line like Key mykey.pub, with mykey.pub replaced by the name of your key file.

Other SSH Servers

For other SSH server software, you should refer to the manual for that server.

Configure WinSCP Session

When configuring session, specify path to your private key on SSH > Authentication page of Advanced Site Settings dialog.

Alternatively, load the private key into Pageant.

Public Key Authentication in Clouds

Cloud providers have typically their own mechanism to setup a public key authentication to virtual servers running in the cloud.

For details see guides for connecting to:

Further Reading

Set up SSH public key authentication :: WinSCP (2024)

FAQs

Set up SSH public key authentication :: WinSCP? ›

You can use Session (Tabs) > Install Public Key into Server command on the main window, or Tools > Install Public Key into Server command on SSH > Authentication page page on Advanced Site Settings dialog. The functionality of the command is similar to that of OpenSSH ssh-copy-id command.

How to setup public key authentication with SSH? ›

The SSH public key authentication has four steps:
  1. Generate a private and public key, known as the key pair. ...
  2. Add the corresponding public key to the server.
  3. The server stores and marks the public key as approved.
  4. The server allows access to anyone who proves the ownership of the corresponding private key.
Aug 10, 2021

How to connect SSH using WinSCP? ›

SSH Key Login
  1. Set File protocol to SFTP .
  2. Fill in the Host name box with the IP address of the server.
  3. Fill in the Username box with your username.
  4. Leave the Password field blank.
  5. Click on Advanced... > SSH > Authentication .
  6. For the Private key file, change the file explorer file type drop-down to All Files (*.

Top Articles
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 5902

Rating: 4.9 / 5 (59 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.