On Windows, you can create SSH keys in many ways. This document explains how to use two SSH applications, PuTTY and Git Bash.
If you don't want to prompt user for a file in which to save the key then, you can add file output flag -f to the command. Ssh-keygen -t rsa -N ' -f /.ssh/idrsa This way user will not be prompted for any input -unless idrsa file(s) already exist. While Encrypting a File with a Password from the Command Line using OpenSSL is very useful in its own right, the real power of the OpenSSL library is its ability to support the use of public key cryptograph for encrypting or validating data in an unattended manner (where the password is not required to encrypt) is done with public keys. The Commands to Run.
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:
Generate Dsa Key Without Prompt Download
- 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.
SSH without password from Windows/Cygwin
First of all the openSSH package must be installed on Cygwin.
Ref:http://www.mines.edu/~gmurray/HowTo/sshNotes.html#ShellNotHome
Note that theseexplanations make reference to your 'home' directory (written'HOME' or '~'). On UNIX machines (including Linux) this isthe directory you land in when you login, and where you keep your files; thislocation is stored in the environment variable 'HOME'. Note that'HOME' is the name of the variable, and that $HOME is the value, e.g.HOME's value may be 'C:nifty'. The naturalHOME for the Windows user Nifty is the existing folder 'Documents andSettingsNifty' but Cygwin and other UNIXrelated applications are not necessarily happy with pathnames that includeblanks, so you should create your own HOME directory for Cygwinas described below.
Windows only
SSH can give youauthenticated and encrypted connections to remote computers. If you set up keysyou can make these connections without passwords. Installing Cygwin is pretty easy but the home directory andpublic/private key business, on Cygwin, is somethingof a pain; it's going to push the 'beginner' envelope but is doable.If you don't mind typing passwords with every connection, you can skip all theWindows HOME business below after installing and running Cygwin.If for some reason you do not wish to install Cygwinon Windows you may want to consider putty. I do not cover how to use puttyhere.
InstallingCygwin on Windows: This is pretty straightforward. Download the Cygwininstallation wizard setup.exe from the Cygwin siteand double-click on it. Most of the default selections in the wizard are fine.Select a place to install Cygwin (recommended:C:cygwin) and select a place to put the installation files (the same placeworks). Choose an ftp site from the list and then review the additionalpackages you want installed. You must select at least the ssh package from the Net section (and the cvs package from Devel if youknow you will need cvs); these are not selected bydefault. You do not need the sources.
Running Cygwin on Windows: You start a Cygwinconsole from the Start menu, and type the commands in that window. (If theshell does not open in the HOME directory, see below). The lscommand lists files and folders ('directories' in UNIX lingo). The cd command enables you to change directories, 'cd .'moves you up a directory. The Cygwin console is muchlike a regular UNIX terminal and may be customized on startup with .bash_profile and .bashrc files inyour HOME directory. Search the web for more about UNIX for beginners. You cansee the (terse) documentation for any command by using the 'man'command, for example, 'man ls' or 'manssh-keygen'.
By the way, Cygwin comes with a small program to set up ssh for you. The command is ssh-user-config, which will create keys and a .ssh directory in your HOMEdirectory. However, it will not create the HOME directory, nor fix your /etc/passwd, nor put the public key on the remote computer, allof which are necessary and described below. I've never used it.
Creatingthe home directory with Cygwin: The Cygwin installation folder contains folders 'usr ' and 'bin'. If there is not one already, add a foldercalled 'home' and in that folder add a folder with some name,typically your user name, e.g., 'nifty'. This will be the folderwhere ssh.exe will look for the .ssh foldercontaining your keys; see below. (Cygwin thinks yourhome is where the line in /etc/passwd says it is, seebelow). Note your home directory does not have to be in Cygwin's'/home' (mine is not), you can put it anywhere, e.g., C:nifty. To dothis, you will have to start a Cygwin console and run
$ cd /
$ mkdir home
$ cd home
$ ln -s /cygdrive/c/niftynifty
The 'ln' command is making a symbolic link, like a Windowsshortcut, from Cygwin's /home/nifty to your C:nifty.Note that '/cygdrive/c/nifty' is Cygwin's way of saying 'C:nifty'. If your HOMEis on another drive, say D:, use the cygwin prefix /cygdrive/d.
Setting the HOMEenvironment variable on Windows: For Win2K/XP right click on 'MyComputer', click on 'Advanced' and 'Environmentvariables'. Add a personal environment variable HOME with value, e.g.,C:cygwinhomenifty (or if you did the ln businessabove, C:nifty). You shouldn't need to reboot.
For Win9x/Me, youmust put a line in your autoexec.bat file (usually C:autoexec.bat) which setsit, e.g.,
or
andreboot. Be sure to edit the autoexec.bat with a text editor (like Notepad) andnot a word processor (like Word).
By the way, environmentvariables are useful for a variety of programs; this is where you would setyour CVS_RSH, ANT_HOME, JAVA_HOME, and JIKESPATH if you were a Java programmerusing cvs with ssh.If you wanted Cygwin commands available from DOSprompts you would append ';C:cygwinbin' toyour PATH variable.
Checking the homein the /etc/passwd file on Windows: In your cygwin root install folder (C:cygwin) there is a folderetc/ containing a file 'passwd' (if thisfile is missing it can be created with the cygwincommand 'makepasswd'). The lines in thisfile contain fields separated by colons (:). In a new cygwininstallation the last line will be for your Windows user name. The last fieldwill be '/bin/bash'. Make sure the next-to-last field in the line foryour Windows user name is '/home/nifty', (it'sOK if 'nifty' is a link). Do not use Windows 'C:'notation. Be sure to edit the /etc/passwd file with atext editor (like Notepad or Wordpad) and not a wordprocessor (like Word).
If the Cygwin shell doesn't open in $HOME: On some some of my installations the CygwinBash shell did not open in $HOME but in /usr/bin (theprompt was '/usr/bin $', not, e.g.,'nifty/ $'). One way to fix this is to put a file '.bash_profile' constainingthe line 'cd $HOME' into your $HOMEdirectory. This is another file which must be created with a text editor.
Linux and Windows
OpenSSH to OpenSSH(ssh2)
Check that ssh functions at all: SSH canreplace telnet even without keys. Suppose you are connecting to the remotecomputer foobar.edu. as user 'dude'. Run
$ ssh [email protected]
The sshwill ask if you want to keep connecting, type 'yes', and then itshould ask for your password and open a shell in dude's home directory on foobar, just like telnet. If this fails, there is a problemsomewhere. Make sure everything is set up right on your end, and also make surethat foobar is accepting ssh Dxo plugins. connections. If it's not, you're wasting yourtime.
Once ssh is functioning we will set upthe keys so it will no longer be necessary to send passwords. If you arecurious about the theory of this then read up on 'public keycryptography'.
Generate Dsa Key Without Prompt Key
Create your keys:You need to create private and public sshkeys and put them in the proper place with the proper permissions. In your homedirectory create a folder .ssh ($ mkdir.ssh), if there is none. Create the keys with thecommand
$ ssh-keygen -t dsa
The ssh-keygenprogram will ask for a passphrase, just hit the'Enter' key unless for some reason you know you want a passphrase. This creates the keys id_dsaand id_dsa.pub and puts them in .ssh/.The private key id_dsa must be readable only by you;change its permissions with
$ chmod 600 . ssh/id_dsa
Put the public keyon the remote computer: In this section we are assuming the remote computer isalso running OpenSSH. Somehow, you must get the .ssh/id_dsa.pub key onto the remote computer, whether byemail, ftp, carrying it over on a floppy (sneakernet),etc.; the cool way to do it is to use scp,which was installed along with ssh. Suppose theremote computer is named foobar.edu, and your account there is'dude'. To copy the file to foobar, run
$ scp .ssh/id_dsa.pub[email protected]:
Don't forget the trailingcolon. You will be asked for dude's password on foobarbefore the copying commences. The file will be copied to dude's home directoryon foobar.
Install the publickey on the remote computer: (We assume the remote computer is running OpenSSH on Linux or UNIX!) Once id_dsa.pubis on the remote computer, login into the remote computer (you can use shh to login as described above). From your home directory(where you should see your newly arrive id_dsa.pub)create a .ssh folder if none exists. Then append yourid_dsa.pub to a file in .sshwith
$ catid_dsa.pub >> . ssh/authorized_keys
This will create the file authorized_keys if none exists. The id_dsa.pubkey may be removed from the remote computer's home directory, if you like. The.ssh folder on the remote computer must have thecorrect permissions, you may set them with Red alert 3 cd key generator.
$ chmod 4755 . ssh
You can also try: chmod -R go-rw ~/.ssh on the remote computer.
Checking the password-lessconnection: Now the command
$ ssh [email protected]
Choices free keys and diamonds generator. should give you a password-less connection to foobar.edu.Likewise, scp should be password-free.
By the way, allthe commands you do by first logging into the remote computer can be doneremotely using ssh. See thedocumentation for details.
-----------------------------------------
Only two things are infinite: the universe and human stupidity. I'm not sure about the former.
-- Albert Einstein
-- Albert Einstein