On Windows, you can create SSH keys in many ways. This document explains how to use two SSH applications, PuTTY and Git Bash.
Ssh-keygen generates, manages and converts authentication keys for ssh (1). Ssh-keygen can create keys for use by SSH protocol version 2. The type of key to be generated is specified with the -t option. From Tools, select Create or Import SSH Keys. From the PuTTY Key Generator dialog, click the Generate button. As the SSH key generates, hover your mouse over the blank area in the dialog. It may take a minute or two. When SSH key generation is complete, you see the public key and a few other fields.
- How to regenerate new ssh server keys This is an unusual topic since most distribution create these keys for you during the installation of the OpenSSH server package. But it may be useful to be able generate new server keys from time to time, this happen to me when I duplicate Virtual Private Server which contains an installed ssh package.
- Use the ssh-keygen command to generate a public/private authentication key pair. Authentication keys allow a user to connect to a remote system without supplying a password. Keys must be generated for each user separately. If you generate key pairs as the root user, only the root can use the keys.
Joyent recommends RSA keys because the node-manta CLI programs work with RSA keys both locally and with the ssh agent. DSA keys will work only if the private key is on the same system as the CLI, and not password-protected.
PuTTY
PuTTY is an SSH client for Windows. You can use PuTTY to generate SSH keys. PuTTY is a free open-source terminal emulator that functions much like the Terminal application in macOS in a Windows environment. This section shows you how to manually generate and upload an SSH key when working with PuTTY in the Windows environment.
About PuTTY
PuTTY is an SSH client for Windows that you will use to generate your SSH keys. You can download PuTTY from www.chiark.greenend.org.uk.
When you install the PuTTY client, you also install the PuTTYgen utility. PuTTYgen is what you will use to generate your SSH key for a Windows VM.
This page gives you basic information about using PuTTY and PuTTYgen to log in to your provisioned machine. For more information on PuTTY, see the PuTTY documentation |
---|
Generating an SSH key
To generate an SSH key with PuTTYgen, follow these steps:
- Open the PuTTYgen program.
- For Type of key to generate, select SSH-2 RSA.
- Click the Generate button.
- Move your mouse in the area below the progress bar. When the progress bar is full, PuTTYgen generates your key pair.
- Type a passphrase in the Key passphrase field. Type the same passphrase in the Confirm passphrase field. You can use a key without a passphrase, but this is not recommended.
- Click the Save private key button to save the private key. You must save the private key. You will need it to connect to your machine.
- Right-click in the text field labeled Public key for pasting into OpenSSH authorized_keys file and choose Select All.
- Right-click again in the same text field and choose Copy.
Importing your SSH key
Now you must import the copied SSH key to the portal.
- After you copy the SSH key to the clipboard, return to your account page.
- Choose to Import Public Key and paste your SSH key into the Public Key field.
- In the Key Name field, provide a name for the key. Note: although providing a key name is optional, it is a best practice for ease of managing multiple SSH keys.
- Add the key. It will now appear in your table of keys under SSH.
PuTTY and OpenSSH use different formats of public SSH keys. If the text you pasted in the SSH Key starts with —— BEGIN SSH2 PUBLIC KEY
, it is in the wrong format. Be sure to follow the instructions carefully. Your key should start with ssh-rsa AAAA…
.
Once you upload your SSH key to the portal, you can connect to your virtual machine from Windows through a PuTTY session.
Git Bash
The Git installation package comes with SSH. Using Git Bash, which is the Git command line tool, you can generate SSH key pairs. Git Bash has an SSH client that enables you to connect to and interact with Triton containers on Windows.
To install Git:
- (Download and initiate the Git installer](https://git-scm.com/download/win).
- When prompted, accept the default components by clicking Next.
- Choose the default text editor. If you have Notepad++ installed, select Notepad++ and click Next.
- Select to Use Git from the Windows Command Prompt and click Next.
- Select to Use OpenSSL library and click Next.
- Select to Checkout Windows-style, commit Unix-style line endings and click Next.
- Select to Use MinTTY (The default terminal of mYSYS2) and click Next.
- Accept the default extra option configuration by clicking Install.
When the installation completes, you may need to restart Windows.
Launching GitBash
To open Git Bash, we recommend launching the application from the Windows command prompt:
- In Windows, press Start+R to launch the Run dialog.
- Type
C:Program FilesGitbinbash.exe
and press Enter.
Generating SSH keys
First, create the SSH directory and then generate the SSH key pair.
One assumption is that the Windows profile you are using is set up with administrative privileges. Given this, you will be creating the SSH directory at the root of your profile, for example:
- At the Git Bash command line, change into your root directory and type.
Change into the .ssh directory
C:Usersjoetest.ssh
- To create the keys, type:
- When prompted for a password, type apassword to complete the process. When finished, the output looks similar to:
Uploading an SSH key
To upload the public SSH key to your Triton account:
- Open Triton Service portal, select Account to open the Account Summary page.
- From the SSH section, select Import Public Key.
- Enter a Key Name. Although naming a key is optional, labels are a best practice for managing multiple SSH keys.
- Add your public SSH key.
When Triton finishes the adding or uploading process, the public SSH key appears in the list of SSH keys.
What are my next steps?
- Adding SSH keys to agent.
- Set up the Triton CLI and CloudAPI on Windows.
- Set up the Triton CLI and CloudAPI.
- Create an instance in the Triton Service Portal.
- Set up the
triton-docker
command line tool. - Visit PuTTYgen to learn more about the PuTTYgen and to seethe complete installation and usage guide.
This chapter explains how to install Cygwin and start the SSH daemon on Microsoft Windows hosts. This chapter is applicable only when you want to install a Management Agent on a Microsoft Windows host, using the Add Host Targets Wizard or EM CLI. In particular, this chapter covers the following:
Important:
Github Ssh Genkey
If you do not want to install Cygwin to deploy Management Agents on Microsoft Windows hosts using the Add Host Targets Wizard or EM CLI, you can choose to deploy Management Agents on these hosts using the PsExec process utility. For information on how to deploy Management Agents on Microsoft Windows hosts using PsExec, see Appendix F.5.1About the Cygwin Requirement for Installing Management Agents
The Add Host Targets Wizard is an application built into the Enterprise Manager Cloud Control console. It offers GUI-rich, interactive screens that enable you to install Oracle Management Agents (Management Agents) on unmanaged hosts and convert them to managed hosts, so that they can be monitored and managed in Enterprise Manager Cloud Control.
When you use the Add Host Targets Wizard or EM CLI to install a Management Agent on a host running on Microsoft Windows, as a prerequisite, you must install Cygwin and start the SSH Daemon on the host. To do so, follow the steps listed in Section 5.3.
Cygwin is essentially a utility that offers a Linux-like environment on a Microsoft Windows host. Technically, it is a DLL (cygwin1.dll
) that acts as a Linux API layer providing substantial Linux API functionality. Once you install Cygwin, you can configure the SSH Daemon on the host. The Add Host Targets Wizard is certified and supported with Cygwin 1.7.
The SSH Daemon enables the Add Host Targets Wizard to establish SSH connectivity between the OMS host and the host on which you want to install a Management Agent. Using this connectivity, the wizard transfers the Management Agent software binaries to the destination host over SSH protocol, installs the Management Agent, and configures it.
5.2 Before You Begin Installing Cygwin
Ssh Keygen Command Options
Before starting with the SSHD setup, ensure you are not using OpenSSH and MKSNT when using the Add Host Targets Wizard. To do so, perform the following checks:
Ensure
OpenSSHbin
andmksnt
are not in yourPATH
environment variable. If they are, remove them by doing the following:Right-click on My Computer and go to Properties.
In the System Properties window, click Advanced.
In this tab, click Environment Variables.
Here, search for the
PATH
system variable, select it, and if theOpenSSHbin
andmksnt
are present inPATH,
click Edit.In the Edit System Variable dialog box, delete these two values from
PATH,
then click OK.
Stop the SSH Daemon if it is running from
OpenSSH
,MKS
or any other vendor. If the SSH Daemon is running, stop it by doing the following:Right-click on My Computer, and select Manage.
In the Computer Management window, in the left pane, expand Services and Applications, and select Services.
In the right pane, click the SSH Daemon/MKS Secure Shell service, then click the Stop button.
Note:
The navigational steps described in this section may vary for different Microsoft Windows operating systems.5.3 Installing Cygwin
To install Cygwin on a Microsoft Windows host, follow these steps:
Access the following URL, then click Install Cygwin:
Download the 32-bit version (if you are running a 32-bit version of Microsoft Windows) or the 64-bit version (if you are running a 64-bit version of Microsoft Windows) of the Cygwin setup executable.
Run the setup executable, then click Next to proceed.
On the Choose Installation Type screen, select Install from Internet, then click Next.
On the Choose Installation Directory screen, enter C:cygwin as the Root Directory, then click Next.
Note:
If you choose to install Cygwin in a different directory, then ensure that you update theSSH_PATH, SCP_PATH, MKDIR_PATH, SH_PATH, CHMOD_PATH
, andTRUE
properties present in the$<OMS_HOME>ouiprovresourcesssPaths_msplats.properties
file to their proper Cygwin binary values, after installing the Enterprise Manager system.For example, if you choose to install Cygwin in the
D:softwarecygwin
directory, then update the specified properties in the following manner:On the Select Local Package Directory screen, select a directory on your local machine where you want to store the downloaded installation files, then click Next.
On the Select Connection Type screen, select appropriate settings to connect to the internet, then click Next.
On the Choose Download Site(s) screen, select any site from the available list, then click Next.
On the select packages screen, ensure that you select the following packages, then click Next:
From the Archive category, select
unzip
andzip
as follows:From the Net category, select
openssh
andopenssl
as follows:After selecting the packages and clicking Next, the Resolving Dependencies screen is displayed. Click Next to proceed.
On the Installation Status and Create Icons screen, do not make any changes. Click Finish to complete the installation process.
5.4 Configuring SSH
This section describes how to configure SSH and test your Cygwin setup after installing Cygwin on a host.
Note:
While configuring SSH, you may need to run theSsh Keygen
cygwin.bat
script. While running cygwin.bat
in Microsoft Windows Server 2008 and Microsoft Windows Vista, ensure that you invoke it in administrator mode. To do this, right-click the cygwin.bat
file and select Run as administrator.To configure SSH and test your Cygwin setup, follow these steps:
After you install Cygwin, navigate to the
C:cygwin
directory, open theCygwin.bat
file in edit mode using any editor, and add the following line before invoking the bash shell.set CYGWIN=binmode ntsec
For example, here are the contents for the
Cygwin.bat
file after adding the above line:To verify if Cygwin (
cygrunsrv)
is installed properly, runC:cygwinCygwin.bat
, and execute the following command:If Cygwin is installed properly, then all the Cygwin help options are displayed on the screen. However, if this command returns an error message, then you may have to reinstall Cygwin.
To configure the SSHD service, run
C:cygwinCygwin.bat
, and execute the following command:After running the command, you are prompted the following questions:
At this point, if you want to use the same name, that is
cyg_server,
enterno.
You are then prompted the following questions:However, if you want to use a different name, enter
yes.
You are then prompted the following questions:If the configuration is successful, you will see the following message:
Backup the
c:cygwinetcpasswd
file and then use any editor to open the file in edit mode. Remove only those entries of the user that you will use to connect to the host on which you want to install a Management Agent. Ask the user to make a backup of thec:cygwinetcpasswd
file before editing.If the user that you are employing to connect to the host on which you want to install the Management Agent is a local user, run
C:cygwinCygwin.bat
and execute the following:If the user you are employing to connect to the host on which you want to install the Management Agent running is a domain user, run
C:cygwinCygwin.bat
and execute the following:
(Only if the Cygwin software you have installed is of version 1.7.32 or higher) Open
C:cygwinetcsshd_config
in a text editor and add the following line to the end of the file:KexAlgorithms diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
(For a domain user only) If the user you are employing to connect to the host on which you want to install the Management Agent is a domain user, do the following to start the SSH daemon:
Right-click on My Computer, and select Manage.
In the Computer Management dialog box that appears, go to Services and Applications, and select CYGWIN sshd.
Right-click CYGWIN sshd and select Properties.
In the Properties dialog box, go to the Log On tab.
Here, specify the domain/user name and password. Click Apply.
Run
C:cygwinCygwin.bat
, and execute the following:Note:
If/var/log/sshd.log
does not exist, you do not have to execute the following commands:
Perform one of the following steps to start the SSH daemon:
Run
C:cygwinCygwin.bat
and execute the following command:/usr/sbin/sshd
OR
Run
C:cygwinCygwin.bat
and execute the following command:cygrunsrv -S sshd
OR
Perform these steps:
Right-click on My Computer, and select Manage.
In the Computer Management dialog box that appears, go to Services and Applications, and select CYGWIN sshd.
Click CYGWIN sshd, then click the Start button.
Note:
If the SSH daemon does not start up, view thec:cygwinvarlogsshd.log
file for information on why the start up failed.You can now test your Cygwin setup.
To do this, go to a different machine (that has the
ssh
client running), and execute the following command:For example,
This command will prompt you to specify the password. When you specify the correct password, the command should return the accurate date.
Note:
If you experience a process fork failure, memory leak error, or a file access error after configuring SSH, view the following website for a workaround:If you are unable to find a workaround for your problem, report your problem to the Cygwin community using the following website:
5.5 After Installing Cygwin and Configuring SSH
After installing Cygwin (as described in Section 5.3) and configuring SSH (as described in Section 5.4), follow these steps:
If the OMS host runs on a Microsoft Windows platform, perform the following on the OMS host:
Right click My Computer, then select Properties. In the window that appears, select Advanced system settings, then select Environment Variables. In the System Variables section, create the
CYGWIN
variable, and specify its value asnodosfilewarning
Note:
You do not need to restart the host after performing this step.Navigate to the Cygwin install directory (that is,
C:cygwin
if you chose to install Cygwin in the default location), open theCygwin.bat
file in edit mode using any editor, then edit the following line:For example, these are the contents of the
Cygwin.bat
file after editing the above line:From the Start menu, select Run. For Open, enter
services.msc,
then click OK. Search for the Cygwin SSHD service and stop it.Navigate to the Cygwin install directory (that is,
C:cygwin
if you chose to install Cygwin in the default location), then runCygwin.bat.
Run the following command to start the SSHD service:Note:
Running this command may return an error mentioning that/var/empty
must be owned by the root user. If you encounter this error, run the following from the Cygwin terminal:After running this command, retry the
$ /usr/sbin/sshd
command.
Perform the tasks mentioned in Step 1 on all the Microsoft Windows target hosts (on which you want to install Management Agents using the Add Host Targets Wizard or EM CLI).