Generating a Key Pair
Generating a public and private key pair for ssh on Unix is really quite simple. Just execute a command, give a passphrase and you are done.On Windows and MacOS, this is very much implementation dependent. You should be able to fill in the (private) key you want to use, somewhere in some configuration window. It is however, often difficult to generate such a key on Windows. It might therefore be easier to generate a public and private key pair on Unix and then use this key for your Windows ssh client software.
In other implementations on Windows and MacOS, it is sometimes difficult to use a (private) key generated somewhere else. There, it might be easier to generate a public and private key pair in the program itself and then use that key on the Unix side.
If you can neither create your own nor use a key from somewhere else, you should look for another ssh implementation.
The passphrase is ssh's equivalent of a password. A passphrase can and should be much longer than a password. And thus it is much more difficult to guess or find by brute force. The passphrase is used to encrypt the (private) key, which is used to encrypt the communication. So without the passphrase, you cannot get to the private key and thus you cannot decrypt (nor encrypt) the exchanged data.
To generate a public and private key pair for ssh on Unix, use the ssh-keygen command. Be sure to check however, which version of the ssh protocol is supported by this command.
Whenever possible, use the OpenSsh implementation, because this supports the widest range of protocols, keys etc.
If you have installed both version 1 and 2 of the ssh protocol implementations, you probably have 2 versions of this command:
- For using ssh protocol 1, you must execute ssh-keygen1.
- For using ssh protocol 2, you must execute ssh-keygen2.
-
The OpenSsh implementations supports 3 kinds of keys:
- ssh-keygen -t rsa1 (the default) generates an RSA key for protocol 1 in the files identity (private key) and identity.pub (public key) in the .ssh directory in your home directory
- ssh-keygen -t rsa generates an RSA key for protocol 2 in the files id_rsa (private key) and id_rsa.pub (public key) in the .ssh directory in your home directory
- ssh-keygen -t dsa generates an DSA key for protocol 2 in the files id_dsa (private key) and id_dsa.pub (public key) in the .ssh directory in your home directory
The ssh-keygen command can transform from and to other formats of keys to be able to connect to/from Ssh2 servers/clients. Consult the man page for a description of the -e and -i options. - Ssh1 stores the private key in the file identity in the .ssh directory in your home directory and the public key in the file identity.pub.
-
Ssh2 does the same in respectively the file
id_dsa_1024_a and id_dsa_1024_a.pub, but in
the .ssh2 directory in your home directory.
Moreover, Ssh2 uses the identification file in the .ssh2 directory in your home directory, to determine which identity (i.e. private and public key pair) to use for the connection. This file must enumerate all such key pairs you have generated and when connecting, they are tried in the order they appear in that file. Consult the man page if you need to know more about using multiple key pairs. You must specify all key pairs you want to use in this file, even if you only have only. Mostly this file will contain just 1 line, containing IdKey id_dsa_1024_a. You must create this identification file yourself, at least with this single line.
You will need the file(s) containing the public key in the next step where you authorize which keys are allowed to connect.

