                                                          Roumen Petrov
                                                        Sofia, Bulgaria
                                                        Tue Jun 30 2026

How to use X.509 certificates with SSH?


Identity or hostkey file contain private key and may contain X.509
certificate that match it. Note that key and X.509 certificate has to
be in PEM format. To use X.509 certificate as identity or hostkey user
should convert certificate in PEM format and append to file. After this
with "ssh-keygen -y ..." user must update "pub" file.
File (identity or hostkey) with X.509 certificate (PKCS#8 key format):
-----BEGIN PRIVATE KEY-----
.....
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
.....
-----END CERTIFICATE-----
File may contain extra X.509 certificates. Extra certificates along
with certificates from X.509 store are used to build chain of X.509
certificates leading to a trusted certificate authority if required by
public key algorithm format. All algorithms defined in RFC6187 are
supported: x509v3-ecdsa-sha2-nistp256, x509v3-ecdsa-sha2-nistp384,
x509v3-ecdsa-sha2-nistp521, x509v3-rsa2048-sha256, and x509v3-ssh-rsa.
Note dss algorithms are excluded from default build configuration
as is used 160-bit sub-group order i.e., 1024-bit key.
Also x509v3-sign-rsa is supported for historical reasons.
Algorithm x509v3-ssh-ed25519 uses public key format described in RFC6187
with signature format described in RFC8709.
Algorithms x509v3-mldsa-44,x509v3-mldsa-65,x509v3-mldsa-87 are
defined in draft-rpe-ssh-x509-mldsa.


1.) server configuration:

1.1.) .../sshd_config

1.1.1.) AllowedCertPurpose sslclient
  The intended use of the X.509 client certificate.

1.1.2.) "X509 store".
  Server use "X509 store" to verify and validate client keys.

1.1.2.1.) CACertificateFile /etc/ssh/ca/ca-bundle.crt
  This file contain multiple certificates of certificate signers in PEM
format concatenated together. You can get a copy from openssl, apache,
KDE, mutt, etc. packages. Original file might is exported from Mozilla
certificate database.

1.1.2.2.) CACertificatePath /etc/ssh/ca/crt
  "Hash dir" with certificates of certificate signers. Each certificate
should be stored in separate file with name [HASH].[NUMBER], where
[HASH] is certificate hash value and [NUMBER] is an integer starting
from zero. Hash is result from command like this:
$ openssl x509 -in certificate_file_name -noout -hash

1.1.2.3.) CARevocationFile /etc/ssh/ca/ca-bundle.crl
  This file contain multiple "Certificate Revocation List" (CRL) of
certificate signers in PEM format concatenated together.

1.1.2.4.) CARevocationPath /etc/ssh/ca/crl
  "Hash dir" with "Certificate Revocation List" (CRL) of certificate
signers. Each CRL should be stored in separate file with name
[HASH].r[NUMBER], where [HASH] is CRL hash value and [NUMBER] is an
integer starting from zero. Hash is result from command like this:
$ openssl crl -in crl_file_name -noout -hash

1.1.2.5.) CAldapVersion
  LDAP protocol version. Default depend from LDAP library.

1.1.2.6.) CAldapURL
  Hostport and dn of LDAP URL. No default value.

1.1.3.) HostKey files...
  Host key may contain X.509 certificate concatenated to private key
both in PEM format.

1.1.4.) X509KeyAlgorithm
  The option list multiple "X.509 Key Algorithms Formats"
  supported by server.
  The format and algorithm precedence are described in sshd_config(5).
  Note first listed format for RSA key-type is used as default in
  signing. The server will accept all listed formats.

NOTES:
- for x509v3-sign-rsa versions before 7.1 use rsa-md5 first. Starting from
  7.1 rsa-sha1 is preferred and client and server identify itself as PKIX
  in comment section of ssh identification string.
- ECDSA support was added in version 8.0. In version 10.0 implementation
  is corrected to conform strictly to RFC 6187 description.
- x509v3-ssh-* (RFC6187) support was added in version 10.0.

1.1.5.) VAType none
  Specifies whether 'Online Certificate Status Protocol' (OCSP) is used
  to validate client X.509 certificates. Specified value is used only
  when SSH is build with OCSP support. See sshd_config(5) man page
  for allowed values and other VA* options.

1.1.6.) KeyAllowSelfIssued no
  Specifies whether self-issued X.509 certificate can be allowed only
  by entry in AuthorizedKeysFile that contain matching public key or
  certificate blob.

1.2.) user files on the server
  Append in USER_HOME/.ssh/authorized_keys a record with following
format:
<KEY_TYPE><SPACE><WORDDN><SPACE>{<Distinguished_Name>|CertBlob}
where:
KEY_TYPE:={x509v3-ecdsa-sha2-nistp256|
	x509v3-ecdsa-sha2-nistp384|
	x509v3-ecdsa-sha2-nistp521|
	x509v3-rsa2048-sha256|
	x509v3-ssh-ed25519|
	x509v3-mldsa-44|
	x509v3-mldsa-65|
	x509v3-mldsa-87} (case sensitive !)
WORDDN:={Distinguished Name|
        Distinguished-Name|
        Distinguished_Name|
        DistinguishedName|
        DN|
        Subject}<WORDDNSUFF>
WORDDNSUFF:='='|':'|''
NOTES:
- WORDDN is case insensitive !

- <Distinguished Name> is like output from command:
$ openssl x509 -noout -subject -in A_CERTIFICATE_FILE -nameopt oneline

- <Distinguished Name> can be in RFC2253 format like output from command:
$ openssl x509 -noout -subject -in A_CERTIFICATE_FILE -nameopt RFC2253

IMPORTANT NOTE (if a distinguished name contain non-ascii characters):
- for versions 6.+:
  ALWAYS use "openssl x509" command option -nameopt !
  The parser don't and won't support output without -nameopt
- for versions prior 6.0:
  The program couldn't parse non-latin subject. Use "blob" format (see below).

- Order of items in <Distinguished Name> is not important and separator can
be symbol "/", "," or mixed. For instance all following subjects are equal:
a)CN=rsa test certificate,OU=SSH Testers,O=Test Team,ST=World,C=XX
b)/C=XX/ST=World/O=Test Team/OU=SSH Testers/CN=rsa test certificate
c)/O=Test Team/OU=SSH Testers/C=XX/ST=World/CN=rsa test certificate
d)O=Test Team,OU=SSH Testers/C=XX,ST=World/CN=rsa test certificate

- CertBlob is base64 encoded sequence of bytes in only one line.

Shell sample:
- "Distinguished Name" format (rsa key):
$ ( printf 'x509v3-rsa2048-sha256 ';
  openssl x509 -noout -subject \
  -in A_SSH_IDENTITY_FILE \
  -nameopt oneline \
  ) >> $HOME/.ssh/authorized_keys

- "blob" format:
$ cat A_SSH_IDENTITY_FILE.pub \
  >> $HOME/.ssh/authorized_keys

NOTES:
- adjust user authorized_keys file ownership - user must have at least
read access.

- When SSH is build with "--disable-x509store" YOU CANNOT USE
"Distinguished Name" format. You should use ONLY "blob" format.
  Option "--disable-x509store" was removed in PKIX-SSH version 9.0.


2.) client settings:

2.1.) IdentityFile
  Depends from client. To use X.509 certificate "SSH id-file" must
contain both sections - private key and certificate in PEM format:
Note: Don't forget to update public key file with command:
$ ssh-keygen -y -f IDENTITY_FILE > IDENTITY_FILE.pub
Command ssh-add use public key file!

2.2.) global ssh_config, $HOME/.ssh/config or command line

2.2.1.) AllowedCertPurpose sslserver
  The intended use of the X.509 server certificate.

2.2.2.) "X509 store".
  Client use "X509 store" to verify and validate server hostkey.
  See p. 1.1.2.) and check the options:
- [User]CACertificatePath;
- [User]CACertificateFile;
- [User]CARevocationFile;
- [User]CARevocationPath;
- [User]CAldapVersion;
- [User]CAldapURL.

Note: When we use own CA we must import CA certificate[s] to
"X509 store". More info on:
  https://roumenpetrov.info/domino_CA/#dca2bundle

2.2.3.) X509KeyAlgorithm
  The meaning of options is same as in server.
  See p. 1.1.4.)

2.2.4.) VAType none
  Specifies whether `Online Certificate Status Protocol' (OCSP) is used
  to validate server X.509 certificates. Specified value is used only
  when SSH is build with OCSP support. See ssh_config(5) man page
  for allowed values and other VA* options.


3.) test X.509 certificates.

3.1.) In SSH build dir run "make check" or "make tests".
  Both commands are equivalent and run regression tests.
  If you want to test only X.509 certificates you can run
$ make check-certs

  If certificate test scripts fail might you should setup test
configuration in the file SSH_SOURCE_PATH/tests/CA/config or
use some environment variables. Used variables are described
later in the document.

  Output from "make check-certs" is in color and when is redirected to
file later we can see content best with command "less -r ...".
  When script run a test command print star '*' followed by simple
information about command. When command succeed script print at right
"done" in GREEN(!) otherwise "failed" in RED(!). After failed command
script show on next lines in RED(!) response, skip execution of next
command/script, print message like this:
....
Testing client and server with X.509 certificates finished.
  status:                                                        failed
....
  Note that failed is in RED(!) and exit code is NONZERO(!).
  Some command in a test script must fail. Part of "simple information"
about command expected to fail is in RED(!). When command fail script
print "done" (THIS IS CORRECT - COMMAND MUST FAIL) and on next lines
print in GREEN(!) response. Usually this occur when server reject logon.
WHEN ALL TESTS SUCCEED output is:
....
Testing client and server with X.509 certificates finished.
  status:                                                        done
....
  Note that "done" is in GREEN(!) and exit code is ZERO(!).

3.1.1.) Description of variables in Makefile file:
  - SHELL
    Used shell to run tests. Supported shell are bash, ksh, zsh and ash.
    Test scripts runs on standard unix sh.
    Example:
    $ make check-certs SHELL=/bin/zsh

    See below how to specify shell at configure time. This is preferred
    setup instead to override shell.

3.1.2.) Description of variables in config file:

3.1.2.1.) main variables:
  - SUDO
    (environment or config) by default is not set.
    on some system sshd must be started as root.
    If necessary configure sudo'ers first and then set variable to sudo
    for test pusposed.
  - TMPDIR
    (environment or config)
    directory for temporary files. If not set its value is selected
    from /tmp, /var/tmp or /usr/tmp.
  - SSH_X509TESTS
    (environment or config)
    list with test scripts. A test script is in file with following
    name: test-<LISTITEM>.sh.inc.
  - OPENSSL_FIPS
    (environment)
    applicable for build with FIPS capable OpenSSL
    see notes below

3.1.2.2.) openssl:
  - OPENSSL
    (environment or config)
    path to openssl binary. The default is result from command:
    `which openssl`.
  - RSA_DIGEST_LIST
    (environment or config)
    list with RSA digests used for intermediate CA with RSA key.
    The default value is set to DEFAULT_DIGEST. Value of DEFAULT_DIGEST
    is sha256 for openssl >= 1.1 and sha1 otherwise. If DEFAULT_DIGEST
    is not set or is empty value RSA_DIGEST_LIST is also empty value.
    In such case list is build at run time from following "sha256 sha1
    md5 mdc2 md4 rmd160" and contain only supported by openssl.

3.1.2.3.) server section:
  Read sshd_config.5 manual page for valid values.
  - SSHD_PORT
    (environment or config)
    Specifies the port number that server listens on and client connect
    to on SSHD_LISTENADDRESS. The default is 20022.
  - SSHD_LISTENADDRESS
    (only in config)
    Same as sshd option "ListenAddress" but without(!) port number.
    The default is "127.0.0.1".
  - SSHSERVER_USEPRIVILEGESEPARATION="yes":
    (only in config)
    sshd "UsePrivilegeSeparation" option.
    if necessary set to "no", to disable privilege separation.
  - SSHSERVER_SYSLOGFACILITY=AUTH
    (only in config)
    sshd "SyslogFacility" option.
  - SSHSERVER_LOGLEVEL=INFO
    (only in config)
    sshd 'LogLevel' option.

3.1.2.4.) certificates:
  - Variables related to test certificates and CA.
    (only in config)

3.1.2.5.) OCSP responder:
  Used only when SSH is build with OCSP support!
  Variables related to OCSP tests.
  - SSH_VA_BASEPORT
    (environment or config)
    Test script run one or more OCSP responders at same once. First
    responder listen on specified port, second on port plus one and
    etc. The default is 20080.
  - SSH_OPENSSL_OCSP_TMOUT=60
    (config)
    Wait specified number of seconds sockets opened by OCSP responders
    to close. After this test script continue with next step.
    This is work around for missing SO_REUSEADDR socket option in
    OpenSSL OCSP responder.
    Remark: set only on ancient OpenSSL releases (< 1.1).

3.1.2.5.) LDAP:
  In use only when SSH is build with LDAP support!
  - SSH_LDAP_DB
    (config)
    Specifies LDAP database type. The default is ldbm.
  - SSH_LDAP_DC
    (config)
    Specifies domain name component in LDAP distinguished name.
    The default is "dc=example,dc=com".
  - LDAPD_PORT
    (environment or config)
    LDAP daemon run by test script run listens on SSHD_LISTENADDRESS
    and this port. The default is 20389.

3.1.2.6.) Key&Certificate from "devices":
  Starting from version 7.0 of X.509 certificate support in ssh client
  you could use X.509 certificates and respective key stored in
  external devices. Access is based on OpenSSL engine.

3.1.2.6.1.) OpenSSL loadable modules - engines
  Following samples show how to use client with NSS engine
  ( https://roumenpetrov.info/e_nss/ ).

  Note that some OS vendors does not build engines if OpenSSL is 3+.
  Also engine module is deprecated in OpenSSL 3.0 and will be removed 4.0.

* Lets first list all engine commands:
$ openssl engine e_nss -vvvv
(e_nss) NSS engine (4.3.1)
     CONFIG_DIR: Specifies the nss config directory
          (input flags): STRING
     DEBUG: debug level (1=info, 2=debug, 3=trace)
          (input flags): NUMERIC
     ERROR_OUTPUT: Specifies the name of output file for debug (stderr by default)
          (input flags): STRING
     LIST_CERTS: List certificates (1=User, 2=CA, 3=All)
          (input flags): NUMERIC
     PRINT_CERT: Search and print certificate by specified nickname
          (input flags): STRING
     LOAD_CERT_CTRL: Return certificate found by specified nickname
          (input flags): [Internal]
     LOAD_CERT_EVP: Return certificate for specified EVP KEY
          (input flags): [Internal]

* Lets try to list certificates:
$ openssl engine e_nss -t -post LIST_CERTS:1
(e_nss) NSS engine (4.3.1)
     [ available ]
[Failure]: LIST_CERTS:1
...:Cannot setup config dir:...
  Above failure show that engine is not properly configured.

  You should find NSS db directory and to configure. For instance:
    $HOME/.mozilla/firefox/<PROFILEHASH>.default
    $HOME/.mozilla/seamonkey/<PROFILEHASH>.default
  , where <PROFILEHASH> is created when you create profile
  for Mozillas application.
  In case of doubt where is located NSS database just run:
$ find $HOME/.mozilla -name cert9.db

  Note samples will use "./tests/nssdb" as path to NSS database.

* Second attempt to list certificates:
$ openssl engine e_nss -t \
  -post CONFIG_DIR:./tests/nssdb \
  -post LIST_CERTS:1
(e_nss) NSS engine (4.3.1)
     [ available ]
[Success]: CONFIG_DIR:./tests/nssdb
nickname='E_NSS Certificate (client-ec1) - E_NSS Test Team cyrillic-АБВ-Яабв-я
greek-ΑΒΓ-Ωαβγ-ω'
...
nickname='E_NSS Certificate (client-rsa) - E_NSS Test Team cyrillic-АБВ-Яабв-я
greek-ΑΒΓ-Ωαβγ-ω'
[Success]: LIST_CERTS:1

* List certificates using STORE utility.
  Note STORE functionality was added in OpenSSL 1.1.1.
  Command assume that engine is set in OpenSSL configuration.
$ openssl storeutl nss:list=all
0: Name: cert=E_NSS Certificate (client-ec1) - E_NSS Test Team cyrillic-АБВ-Яабв-я
greek-ΑΒΓ-Ωαβγ-ω
...
6: Name: cert=E_NSS Certificate (client-rsa) - E_NSS Test Team cyrillic-АБВ-Яабв-я
greek-ΑΒΓ-Ωαβγ-ω
Total found: 7

* Extract information using STORE utility.
$ openssl storeutl -passin pass:... nss:"$nickname"
0: Pkey
1: Certificate
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
Total found: 2
  , where $nickname is one of names returned by "list"-URI.
  Note that key is not exportable i.e., after Pkey is printed next item.

* Let setup ssh_engine:
$ cat ssh_engine
Engine e_nss
          CONFIG_DIR ./tests/nssdb

  The SSH configuration match above openssl test command.
  Ref. to manual page ssh_engine(5) for details.

* Let connect to server:
  Test assume that ssh server is setup to accept client certificate.
  Following commands shows use of engine or store.
$ ssh -E ssh_engine \
  -i engine:e_nss:"\"E_NSS Certificate (client-ec1) - E_NSS Test Team...\"" \
  ....
  where dots replace part of actual nickname, -E specify engine
  configuration file instead default one, -i specify IdentityFile in
  format engine:[ENGNAME]:[KEY_SEARCH_CRITERIA].
  Note quotes as nickname is with space characters.

$ ssh -E ssh_engine \
  -i store:nss:"\"E_NSS Certificate (client-ec1) - E_NSS Test Team...\"" \
  ....

3.1.2.6.2.) OpenSSL loadable modules - providers
  Following samples show how to use client with NSS provider
  ( https://roumenpetrov.info/e_nss/ ).

  Note that is OpenSSL 3.0 functionality.
  It allows use of certificates and/or keys from various sources like
  NSS, PCKS#11, TMP2 providers.

* Let list available providers:
$ openssl list -providers
Providers:
  default
    name: OpenSSL Default Provider
    version: 3.6.1
    status: active
  test_nss
    name: NSS provider
    version: 1.1
  Note that is of provider depends on OpenSSL configuration while the name
  is from provider code. In above case "NSS provider" is activated.

  The STORE utility is used to list available certificates and to print
  information for key and/or certificate.
$ openssl storeutl nss:list=all
...
$ openssl storeutl -passin pass:... nss:"$nickname"
...

* Let connect to server:
  Test assume that ssh server is setup to accept client certificate.
  Following command shows use of store.
$ ssh \
  -i store:nss:"\"E_NSS Certificate (client-ec1) - E_NSS Test Team...\"" \
  ....

3.1.2.7.) FIPS capable openssl:
  Starting from version 7.1 of X.509 certificate support all programs
  initialize openssl in FIPS mode if environment variable OPENSSL_FIPS
  is set.
  Note that you could run X.509 certificate tests in FIPS mode but
  you must ensure that test certificates are created in fips mode.
  So first go to $(top_builddir)/tests/CA and run "make clean".
  Then return to top build directory and run the tests again.
  OPENSSL_FIPS=1 make check-certs ....

3.1.2.8.) Key&Certificate from "PKCS#11 token":
  Version 7.1 add support for certificate and key obtained from
  pkcs11 module. Only RSA algorithm was supported. Release 8.8
  add support for EC based certificates and keys. To test
  functionality PKCS#11 module(1) has to be present. Initialisation
  of module require respective utily(2). The certificates and keys
  are loaded by PKCS#11 tool(3). The test script search for
  libsofthsm2.so(1), softhsm2-util(2), and pkcs11-tool(3) in
  some well known paths. They could be set by relevant environment
  variables TEST_SSH_PKCS11(1), SOFTHSM2_TOOL(2), and PKCS11_TOOL(3).

3.1.3.) Sample commands to run tests:
$ OPENSSL=/usr/local/ssl/bin/openssl make check-certs
$ SSHD_PORT=1122 SSH_X509TESTS="agent blob_auth" make check-certs
$ RSA_DIGEST_LIST="sha1 md5" make check-certs
$ make check-certs SHELL=/bin/ksh

When check fail see "Troubleshooting" later in document.

Note: starting from version 7.0 of X.509 certificate support test use
shell specified during configuration by CONFIG_SHELL=..., i.e.
$ CONFIG_SHELL=/bin/ksh .../configure ...
$ ...
$ make check-certs

3.2.) Current test scripts uses only rsa as server hostkey.
  To test sshd with X.509 certificate please find in file
ssh_x509tests.sh variable TEST_SSHD_HOSTKEY and change it. Sample:
TEST_SSHD_HOSTKEY="$CWD/testhostkey_rsa-rsa_sha256"


3.3.) Test SecSH from "Microsoft Windows OS-es".
  This is not part of document.
Tips: use created after "make check-certs" files:
- convert SSH_BUILD_PATH/tests/CA/ca-test/crt/*crt.pem CA
  certificates from PEM to DER format and import in
  "Windows keystore";
- import SSH_BUILD_PATH/tests/CA/testid_*.p12 files in
  "Windows keystore";
- setup your client to use certificate[s](see SecSH client manuals).
DON'T FORGET TO REMOVE entries from "Windows keystore" after test!


3.4.) Go to SSH_BUILD_PATH/tests/CA and run command "make clean" to
remove all client/server and CA files.


3.5.) files in SSH_SOURCE_PATH/tests/CA directory:
config:
  Configuration file.

compat:
  Shell settings and command compatibility.

env.in:
  Template file.
  Contain variables extracted from build configuration.

pkcs11-env:
  File with functions used to tests PKCS#11 tokens.

1-cre_cadb.sh:
  Create "Test CA" directories and files.

2-cre_key.sh
  Create ssh keys. Use test configuration, i.e.
  run ssh-keygen in FIPS mode if requested.

2-cre_cakeys.sh:
  Create "Test CA" private keys and certificates.

3-cre_certs.sh:
  Create client/server certificates.
  This command create files with mask
  "PATH_TO_KEYFILEn-<SIGNATURE_ALGORITHM>[.<SUFFIX>]"
  , where <SIGNATURE_ALGORITHM> is in format "rsa_<DIGEST>" or "ec256".
  DIGEST are form variable "RSA_DIGEST_LIST" specified in "config"
  file. Files without suffix are SSH identity or hostkey files.
  File with .pub suffix contain SSH public key (BLOB format).
  File with .crt suffix contain OpenSSL "text output" for identity
  files. Files with .p12 suffix are for "Microsoft Windows keystore".
  Note: .p12 = .pfx for Windows.

4-cre_crls.sh:
  Revoke part of client certificates.

5-cre_ldap.sh
  Create LDAP ldif files and slapd config.

verify.sh:
  To check certificates against "Test CA". Note: check only
  testid_*.crt and testhostkey_*.crt files in current directory.

functions:
  Common useful functions.

ssh_tests.sh:
  Main test script - call other testscripts.

  Test shell scripts listed in execution order:
test-blob_auth.sh.inc,
test-dn_auth_file.sh.inc,
test-dn_auth_path.sh.inc,
test-agent.sh.inc,
test-crl.sh.inc,
test-self.sh.inc,
test-alg.sh.inc,
test-hostalg.sh.inc,
test-algfmt.sh.inc,
test-store_file.sh.inc,
test-ocsp.sh.inc.
  See DESCRIPTION in each file.

  Optional test scripts:
test-pkcs11.sh.inc,
test-pkcs11_eng.sh.inc,
test-pkcs11_prov.sh.inc,
test-nss_eng.sh.inc,
test-nss_prov.sh.inc,
test-tpm2_prov.sh.inc,
test-by_ldap.sh.inc.

Note that hostbased authentication we cannot test without to install.
Generated testhostkey_* certificates are with sslserver and sslclient
purposes and you can use them to test manually hostbased authentication.


4.) Troubleshooting
"make check-certs" fails on:

4.1.) "generating a new ... private key for the TEST CA ..."
Usually this happen on system without /dev/{u}random.
In file [BUILDDIR]/tests/CA/ca-2.log we can see a message:
"... PRNG not seeded ...".
Read again WARNING.RNG from SSH sourcedir and/or
https://www.openssl.org/support/faq.html

4.1.1.) reconfigure your system and/or openssl
4.1.2.) or do next
4.1.2.1.) install SSH :-( otherwise later "make check-certs"
(ssh-keygen) fail with message:
"couldn't exec '.../libexec/ssh-rand-helper': ..."
and second ./ssh-rand-helper fail with message:
"couldn't read entropy commands file ../ssh_prng_cmds: ..."
Tip: configure SSH with prefix for example $HOME/test

4.1.2.2.) run:
ssh-rand-helper
rm -f $HOME/.rnd
ln -s .ssh/prng_seed $HOME/.rnd
Note: Support for ssh-rand-helper was removed in 2011.

4.1.2.3.) test openssl with command:
/usr/local/ssl/bin/openssl genrsa -des3 -passout pass:change_it
Tip: before to create every key with OpenSSL run ssh-rand-helper !

4.1.2.4.) run again "... make check-certs ..."

4.2.) fail on first check: "* rsa_sha1 valid blob              failed"
- Usually SUDO command is not set. See p. 3.1.2.1.
- When you build with tcpwrappers your hosts.allow must permit
connections from localhost, otherwise you can see in failed message
text like this: "... connection closed by remote host ..."

4.3.) fail on "starting OCSP responder(XXX) on YYY:NNNNN       failed"
- Ensure sequence of about six free ports and use SSH_VA_BASEPORT
  to specify first of them.
- Ensure enough timeout previous running OCSP responders to free
  ports. Increase value of SSH_OPENSSL_OCSP_TMOUT in test config file.


5.) FAQ

Q.) How to convert a certificate from DER to PEM format?
A.) Run command "openssl x509 ..." with command line options
-inform/-outform  - you can select one of formats: DER, NET or PEM.
The default is PEM.

Q.) How to convert pfx to p12 file?
A.) Just change file extension ;-).

Q.) How to use my p12 file in SSH as identity?
A.) Run commands:
$ openssl pkcs12 -in FILE.p12 -clcerts > id_x509
$ ssh-keygen -f id_x509 -y > id_x509.pub
  Don't forget to set properly permission on file id_x509, as
example "chmod 600 id_x509".
  Note name of identity file can be one of defaults:
  'id_ecdsa', 'id_ed25519', or 'id_rsa'.
  Configure client.

Q.) How to use p12 file in SSH as hostkey?
A.) Note that host keys are password less!
  It is similar to client identity.
  Remember umask settings.
  Run as root commands:
# umask 0077
# openssl pkcs12 -in FILE.p12 -clcerts > ssh_host_x509
  Note: you must enter export password!
# ssh-keygen -p -f ssh_host_x509 -N ''
  Now hostkey file is password less !
# ssh-keygen -f ssh_host_x509 -y > ssh_host_x509.pub
  Restore umask settings.
  Note name of hostkey file can be one of defaults:
  'ssh_host_ecdsa_key', 'ssh_host_ed25519_key', or 'ssh_host_rsa_key'.
  Configure server, test configuration with command
# sshd -t ..../sshd_config
  and start/restart the server. Don't forget to inform users
  that hostkey is changed!

Q.) How to import CA certificates and/or CRLs in LDAP?
A.) You should create a ldif file with LDAP entries that contains
  binary attributes "cACertificate" and/or "certificateRevocationList"
  and to specify path to file with certificate or CRL in DER format.
  Entry should contain objectClass "pkiCA". See definition in core
  LDAP schema. After this to use command ldapadd or ldapmodify to
  add/modify LDAP data. See command manual pages.

  As example when you build SSH with ldap queries after
  regression test see content of file
    $(top_builddir)/tests/CA/ldap/ca.ldif .
  This file is created by the script
    $(srcdir)/tests/CA/5-cre_ldap.sh
  and entries are added to LDAP with command:
$ ldapadd -x -w secret -D cn=... -H ldap://... \
    -f .../ca.ldif .
  See ldapadd manual page for options meaning.

Q.) How to build with FIPS capable OpenSSL ?
A.) At configure time you must set environment variables:
  CC : openssl fips compiler - fipsld
  FIPSLD_CC : actual compiler to be used by openssl fips compiler
  Note those instruction are for FIPS 1.2 module.

  Sample command:
$ CC=gcc FIPSLD_CC=fipsld .../configure ...

  Next verify configure script output:
....
   Actual compiler: gcc
          Compiler: FIPSLD_CC=$(FIPSLD_CC) fipsld
....


Enjoy ;-)
