Chapter 35. SSH Keys
Business Central provides an SSH keystore service to enable user SSH authentication. Business Central provides a configurable default SSH keystore, extensible APIs (for custom implementations), and support for multiple SSH public key formats.
You can access the SSH Keys option on the Business Central Settings page to register your SSH public keys.
35.1. Default SSH keystore
The default SSH keystore included with Business Central provides a file-based storage mechanism to store a user’s public keys. By default, Business Central uses the *.security
folder as the root directory. However, you can also use a custom storage path by setting the value of the appformer.ssh.keys.storage.folder
system property to point to a different folder.
The SSH public keys are stored in the {securityFolderPath}/pkeys/{userName}/
folder structure.
Each SSH public key consists of the following files, located in the storage folder:
{keyId}.pub
: This file contains the SSH public key content. As the file name determines the logic key ID on the system, ensure that the file name is not modified during run time.For example:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDmak4Wu23RZ6XmN94bOsqecZxuTa4RRhhQmHmTZjMB7HM57/90u/B/gB/GhsPEu1nAXL0npY56tT/MPQ8vRm2C2W9A7CzN5+z5yyL3W01YZy3kzslk77CjULjfhrcfQSL3b2sPG5jv5E5/nyC/swSytucwT/PE7aXTS9H6cHIKUdYPzIt94SHoBxWRIK7PJi9d+eLB+hmDzvbVa1ezu5a8yu2kcHi6NxxfI5iRj2rsceDTp0imC1jMoC6ZDfBvZSxL9FXTMwFdNnmTlJveBtv9nAbnAvIWlilS0VOkdj1s3GxBxeZYAcKbcsK9sJzusptk5dxGsG2Z8vInaglN6OaOQ7b7tcomzCYYwviGQ9gRX8sGsVrw39gsDIGYP2tA4bRr7ecHnlNg1b0HCchA5+QCDk4Hbz1UrnHmPA2Lg9c3WGm2qedvQdVJXuS3mlwYOqL40aXPs6890PvFJUlpiVSznF50djPnwsMxJZEf1HdTXgZD1Bh54ogZf7czyUNfkNkE69yJDbTHjpQd0cKUQnu9tVxqmBzhX31yF4VcsMeADcf2Z8wlA3n4LZnC/GwonYlq5+G93zJpFOkPhme8c2XuPuCXF795lsxyJ8SB/AlwPJAhEtm0y0s0l1l4eWqxsDxkBOgN+ivU0czrVMssHJEJb4o0FLf7iHhOW56/iMdD9w== userName
.{keyId}.pub.meta
: This file contains the key metadata in JSON format. A new metadata file is dynamically generated if a key has no metadata.For example:
{ "name":"Key", "creationDate":"Oct 10, 2018 10:10:50 PM", "lastTimeUsed":"Oct 11, 2018 12:11:23 PM" }
35.2. Custom SSH keystore
You can extend and customize the default SSH keystore according to your requirements. Use the appformer.ssh.keystore
system property to specify the Java class name of the SSH service to use. If this property is not defined or it contains an incorrect value, then the default SSH keystore is loaded.
To create a custom implementation of the SSH keystore, your Java class must implement the org.uberfire.ssh.service.backend.keystore.SSHKeyStore
class defined in the uberfire-ssh-api
module.
35.3. Creating an SSH key
Before you can add or register SSH keys to Business Central, you must generate an SSH key on your system.
Procedure
- Open a command terminal on your system.
Run the
ssh-keygen
command to create the SSH key as shown in the following example, where<user_login>
is your user name:ssh-keygen -t rsa -b 4096 -C "<user_login>"
NoteThe SSH key formats supported by Business Central keystore are
ssh-rsa
,ssh-dss
,ecdsa-sha2-nistp256
,ecdsa-sha2-nistp384
, andecdsa-sha2-nistp521
.When prompted, press Enter and accept the default key file location as shown in the following example, where
<user_login>
is your user name:Enter a file in which to save the key (/home/<user_login>/.ssh/id_rsa): [Press enter]
At the command prompt, enter and confirm the passphrase:
Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again]
Start the
ssh-agent
:eval "$(ssh-agent -s)" Agent pid <any-number-here>
Add the new SSH private key to the
ssh-agent
. If you have used a different key name, replaceid_rsa
in that code:ssh-add ~/.ssh/id_rsa
35.4. Registering your SSH public key with the SSH keystore
You must register your newly created SSH public key with the Business Central keystore.
Procedure
- Open a command terminal on your system.
Run the
cat
command as shown in the following example, whereid_rsa
is your key name:cat ~/.ssh/id_rsa.pub
- Copy the contents of your SSH public key.
- In Business Central, select the Admin icon in the top-right corner of the screen and select SSH Keys.
- On the SSH Keys page, click Add SSH Key.
In the Add SSH Key window, enter a name in the Name field and copy the contents of the SSH public key to the Key field.
NoteThe Name and the Key fields are mandatory.
- Click Add SSH Key to register the key.
35.5. Deleting an SSH key
You can delete an SSH key from Business Central by from the SSH Keys page.
Procedure
- In Business Central, select the Admin icon in the top-right corner of the screen and select SSH Keys.
- On the SSH Keys page, click the delete icon of the SSH key you want to delete.
- Click Delete SSH Key to confirm the deletion.