Title: SSH Key Pair Authentication with SFTP for File Uploads on a Windows Server 2019 Cloud Server
This article explains how to set up SSH key pair authentication for SFTP file uploads on a Windows Server 2019 cloud server. This method is beneficial for vendors who use FTP sites and ensures a smooth workflow during development.
Prerequisites
- A Windows Server 2019 cloud server.
- An SFTP client, such as FileZilla.
Steps to Set Up SSH Key Pair Authentication
Step 1: Generate SSH Key Pair
-
Open a terminal or command prompt on your local machine.
-
Run the following command to generate an SSH key pair:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Replace [email protected] with your email address.
-
When prompted, enter a file name for the key pair (e.g.,
id_rsa). Press Enter to accept the default location. -
Enter a passphrase for the key pair when prompted. This passphrase will be required every time you use the key pair.
Step 2: Copy the Public Key
- Navigate to the
.sshdirectory created in your home directory:
cd ~/.ssh
- Copy the public key (
id_rsa.pub) to your clipboard.
Step 3: Upload the Public Key to the Server
-
Open your SFTP client (e.g., FileZilla) and connect to your Windows Server 2019 cloud server using your SFTP credentials.
-
Navigate to the
.sshdirectory on the server and create a new directory for your key pair:
mkdir your_username
Replace your_username with your username on the server.
- Upload the public key (
id_rsa.pub) to the newly created directory on the server.
Step 4: Configure SSH Key Pair Authentication
- On the server, open the
authorized_keysfile in the.sshdirectory using a text editor (e.g., Notepad):
notepad authorized_keys
-
Paste your public key into the file and save it.
-
Set the correct permissions for the
.sshdirectory and its contents:
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
Step 5: Test the Setup
-
Attempt to connect to the server using your SFTP client.
-
When prompted, enter your username and password. If the SSH key pair authentication is set up correctly, you will be logged in without needing to enter your password again.