If your user is an administrator, you need to create a special authorized key file. This is where things get kind of confusing.
Installing the Key by Hand (Windows Administrator)īy default, OpenSSH Server for Windows comes with a special configuration for Windows Administrators. Now, copy the contents of your id_rsa.pub file into /home/demo/.ssh/authorized_keysĪnd you’re done. #Create the directory if it doesn’t exist This is all done from the user’s perspective, so the files need to be created in their home directory and they need to own it.
You can however either WSL or SSH into the WSL Ubuntu shell and do everything there. If you’re running a windows client or have a windows server, you won’t have the convenience of ssh-copy-id. What this utility is doing is SCPing the specified public key to the users /home/demo/.ssh/authorized_keys file and setting that appropriate permission. Now try logging into the machine, with: "ssh check to make sure that only the key(s) you wanted were added.
When prompted, provide the password we created in part 1. There’s no ssh-copy-id for Windows local machines and the OpenSSH Server for Windows lacks the Linux utilities that copy the key once it gets to the server. Windows users, unfortunately, are out of luck on both sides. You will need to password-based authentication enabled to use this command, because you must login as that user. You will need the destination user created and configured on the development server.
Installing the Public Keyįor WSL Ubuntu from a Linux or Mac, you can install the key onto the OpenSSH Server with one command. Github provides an exhaustive guide here. The steps are different for Windows, Mac and Linux. The last step is to load the ssh key into the local development machine’s key agent. It will be located in the user’s ~/.ssh/id_rsa.pub file. Once you have your key loaded, copy the contents of the id-rsa.pub and get ready to install it on the server. You’ll be prompted to provide the password whenever you try to use the key unless you load it into an agent as detailed here. Best practices recommend generating a key with a password. We’re going to go through the defaults without a password using RSA.
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'Īdd-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 # Make sure that OpenSSH is available for your Windows
On the local development machine, we need to make sure we have a client. The remote development server needs to have the line below in its sshd_config and to be restarted like we did in Part 1. Windows users, you’ll need to install the ssh client on your local development machine. Linux and Mac users will have all the tools you need. On your local developer machine, you need to generate a public and private key. Setting up Private and Public Keys on the Local Machine Part three covers installing and configured VS Code’s remote development capabilities. This post walks through the setup of pre-shared keys for password-less login.
In part one of this series, we showed you how to configure a Windows 2019 EC2 instance to run an OpenSSH Server to pave the way for secure, remote development. Configuring SSH for Public Key Authentication