# Ghidra Server README

## Table of Contents

- Introduction
- Java Runtime Environment
- Server Configuration
- Server Memory Considerations
- Note regarding use of DNS (name lookup service)
- User Authentication
- SSH User Authentication
- Server Options
- Running Ghidra Server on Microsoft Windows

- Server Scripts
- Running Server in Console Window
- Install as Automatic Service
- Uninstall Service

- Running Ghidra Server on Linux or Mac-OSX

- Server Scripts
- Running Server in Console Window
- Install as Automatic Service
- Uninstall Service

- Server Administration
- Repository Backup
- Clearing Obsolete Checkouts
- PKI Certificates
- Managing PKI Certificate Authorities
- Upgrading the Ghidra Server Installation
- Troubleshooting

- Failures Creating Repository Folders / Checking in Files
- Client/Server connection errors
- MS Windows - ERROR Missing Temp Directory
- MS Windows 7 and 8 - ghidraSvr.bat, svrInstall.bat, or svrUninstall.bat Error
- Linux - SELinux must be disabled
- Linux - Potential hang from /dev/random depletion

## Introduction

The Ghidra Server is incorporated into the standard Ghidra software distribution. Simply unpack the Ghidra distribution, configure the Ghidra Server and perform the OS-specific install and you should have the server running in no time.

The Ghidra Server utilizes the YAJSW Java service wrapper to launch the application and provides OS specific scripts which enable the application to run as a service.

NOTE: It is very important that only a single server instance is running against any given server repositories directory. This can be assured if only the default port is ever used. The daemon/service mechanism assumes that only one instance of the service exists. Attempting to run a second concurrent instance may lead to difficulties and is not supported.

NOTE: It is highly recommended that the installation files for Ghidra reside on a local drive and that the intended Ghidra Server process owner is granted full access to the Ghidra installation directory (this is frequently not the case for NFS/SMB mounted home directories).

NOTE: It is highly recommended that you establish a repositories directory outside of your Ghidra installation directory so that it may be re-used more easily with future upgraded installations of Ghidra.

You may also refer to the <typewriter>InstallationGuide.html</typewriter> file within the <typewriter>docs</typewriter> subdirectory for general installation information.

(Back to Top)

## Java Runtime Environment

The installation of a suitable Java Runtime Environment must be completed before installing or running the Ghidra Server. Please refer to the Ghidra Installation Guide to identify a suitable version. Since the Ghidra Server is unable to interactively identify a Java installation at runtime it must rely upon the setting of JAVA_HOME, execution search PATH or the use of standard Java installation locations. It is important to consider the service execution environment which may differ from the administrator who may be installing the service. For this reason use of an installed Java release may be preferable over one that is simply unpacked to an arbitrary location.

(Back to Top)

## Server Configuration

Before installing and running the Ghidra Server, the <typewriter>server/server.conf</typewriter> file must be modified to suit your particular needs. Within this file, locate the lines labeled:

        wrapper.app.parameter.#

These lines correspond to a sequential list of server command line arguments - be sure not duplicate a parameter number. The comments within this file indicate the available command line arguments which should be specified here based upon the desired user authentication, repositories directory location and other associated options.

You should generally avoid using the default repositories location and specify a location outside your installation directory using an absolute path specification.

When upgrading your Ghidra installation, you will need to copy your app parameters from your old <typewriter>server.conf</typewriter> to the new <typewriter>server.conf</typewriter>. Do not copy the entire <typewriter>server.conf</typewriter> file as this may prevent the server from running properly. If running as a service, you must run the <typewriter>server/svrUninstall</typewriter> script from the old installation before running the <typewriter>server/svrInstall</typewriter> script from the new installation. Using a non-default repositories directory outside your Ghidra installation will simplify the migration process.

(Back to Top)

## Server Memory Considerations

The Ghidra Server currently maintains an in-memory state for all repositories. We are aware that this can limit the scalability of the Ghidra Server. The maximum memory used by the process can be set within the <typewriter>server/server.conf</typewriter> file by adjusting the following setting:

        wrapper.java.maxmemory

WARNING! There are currently no safeguards when insufficient memory is available to the Ghidra Server and can cause severe failure if an out of memory error occurs.

The following formula can be used to approximate an appropriate setting for this <typewriter>maxmemory</typewriter> value where <typewriter>FileCount</typewriter> represents the maximum number of repository files and <typewriter>ClientCount</typewriter> is the number of active Ghidra clients connected at one time.

        wrapper.java.maxmemory = 16 + (32 * FileCount/10000) + (2 * ClientCount)

Example:

        100,000 files and 25 connected Ghidra clients
        16 + (32 * 100000/10000) + (2 * 25) = 386
        wrapper.java.maxmemory=772    (2 * 386, see NOTE below)

NOTE: Due to the dynamic memory demands on the server not considered by this calculation (e.g., open file handles, etc.), the actual maxmemory setting used should be larger than the calculated value. At a minimum, it is recommended that the calculated value be doubled, and a larger value may be appropriate based upon server loading.

The Java VisualVM tool (if available for your host) may also be used to examine memory usage while the server is running. This tool is NOT provided with any Ghidra distribution.

(Back to Top)

## Note regarding use of DNS (name lookup service)

Both Ghidra Server and client application make extensive use of forward and reverse network name lookups. If this service is not properly configured on your network and hosts, names may fail to be resolved or in certain cases cause severe performance delays due to improperly serviced DNS name/address queries.

By default the server will attempt to identify an appropriate remote access IPv4 address which will be written to the log at startup. In addition, the server will listen for incoming connections on all IPv4 interfaces by default. It is important to understand the difference between the published remote access address and the listening address (i.e. interface) which are both configurable. See the <typewriter>-ip</typewriter> and <typewriter>-i</typewriter> options in the Server Options section for more details.

(Back to Top)

## User Authentication

The Ghidra Server has been designed to support many possible user authentication modes:

- No authentication - any user which has been added to the server may connect without password or credentials.
- Local Ghidra password (<typewriter>-a0</typewriter>) - passwords associated with each user added to the server are maintained in the <typewriter>users</typewriter> file located within the repositories directory. The user will be prompted for this password when connecting to the server. The default password <typewriter>changeme</typewriter> is used when a user is first added or when the user is reset (see Server Administration). This default password must be changed by the user to avoid its expiration.
- Active Directory via Kerberos (<typewriter>-a1</typewriter>) - user authentication is performed against your local Active Directory system using Kerberos to do so. The -d<ad_domain> argument is required to specify the domain name of your Active Directory system.

  It is also possible to authenticate against your Active Directory system using LDAP. See the LDAP example when using JAAS -a4 mode.

- PKI authentication (<typewriter>-a2</typewriter>) - user authentication is performed using PKI user certificates. When using this mode, the distinguished name (DN) for each user must be associated with each server User ID (see Server Administration). In addition, each user must configure Ghidra with the location of their signing key/certificate keystore file (see PKI Certificates for more information).

  Please note that each user's certificate must be issued by a trusted certificate authority which has been properly added to the Ghidra Server's <typewriter>cacerts</typewriter> file. See Managing PKI Certificate Authorities for more information.

  In an attempt to simplify the determination of user DN's, a log file (<typewriter>UnknownDN.log</typewriter>) records user DNs which are unknown. After adding a user to the server, ask the user to attempt a login using their PKCS certificate. This should result in their DN being recorded to this log file. The server administrator may now copy the appropriate DN from this log file when assigning the DN for a user.

- JAAS - Java Authentication and Authorization Service (<typewriter>-a4</typewriter>) - user authentication is delegated to the JAAS subsystem. The -jaas <config_file> argument is required to specify the JAAS config file. The JAAS config file supplied (server/jaas.conf) contains various example configurations which may be used to establish an 'auth' configuration section. None of the example configurations use the 'auth' name so they will be ignored by default.

  JAAS is architected similar to Linux/Unix PAM, where a named authentication configuration is possibly composed of several different modules. Ghidra's support of JAAS only handles single simple JAAS modules that requests the name and password from the user.

  Some known JAAS login modules:

  - com.sun.security.auth.module.LdapLoginModule - allows authentication to an LDAP server. There is an example of using this module to authenticate against an Active Directory system in the jaas.conf file.
  - net.sf.jpam.jaas.JpamLoginModule - (Linux/Unix server only) allows authentication against the local PAM configuration. You will need to download JPAM from SourceForce and install the libraries in the necessary locations. See the example in the jaas.conf file.
  - ghidra.server.security.loginmodule.ExternalProgramLoginModule - spawns an external program for each authentication request, and uses the external program's exit code as the indicator of successful authentication.

    There is an example (and non-useful) implementation of an external authenticator provided with the Ghidra instalation called server/jaas_external_program.example.sh.

    This login module strives to be compatible with Apache's mod_authnz_external API, and you should be able to use any mod_authnz_external authenticator with Ghidra.

    The external program is fed the username\n and password\n on its STDIN (ie. two text lines). The external authenticator needs to exit with 0 (zero) error level if the authentication was successful, or a non-zero error level if not successful.

  - com.sun.security.auth.module.Krb5LoginModule - not recommended - this login module is used in the -a1 Active Directory via Kerberos authentication mode, and as such you should use it that way.
- Use of an SSH pre-shared key (<typewriter>-ssh</typewriter>) is supported as an alternate form of authentication when using Local Ghidra password (<typewriter>-a0</typewriter>). This SSH authentication is currently supported by the Headless Analyzer only. See SSH User Authentication for configuration details.

(Back to Top)

## SSH User Authentication

When the <typewriter>-ssh</typewriter> option has been included in conjunction with password based authentications mode (<typewriter>-a0</typewriter> a user's SSH public key may be added to the server to facilitate access by a Headless Analyzer. An SSH public key file must be added to the server repository for each user who requires headless SSH authentication. The SSH public key file (e.g., <typewriter>id_rsa.pub</typewriter>) must be copied to the <typewriter>repositories/~ssh</typewriter> subdirectory to a file named <typewriter><username>.pub</typewriter>. Removing the file will eliminate SSH based authentication for the corresponding user. When creating the <typewriter>~ssh</typewriter> subdirectory, it should be owned by the Ghidra Server process owner with full access and any SSH public keys readable by the process owner. Changes to the SSH public key files may be made without restarting the Ghidra Server.

(Back to Top)

## Server Options

- Networking options
  - <typewriter>-ip <hostname></typewriter>
    Identifies the remote access hostname (FQDN) or IPv4 address which should be used by remote clients to access the server. By default the host name reported by the operating system is resolved to an IPv4 address, if this fails the local loopback address is used. The server log will indicate the remote access hostname at startup. This option may be required when a server has multiple IP interfaces, relies on a dynamic DNS or other network address translation for incoming connections. This option establishes the property value for java.rmi.server.hostname.
  - <typewriter>-i <#.#.#.#></typewriter>
    Forces the server to be bound to a specific IPv4 interface on the server. If specified and the <typewriter>-ip</typewriter> option is not, the address specified by <typewriter>-i</typewriter> will establish the remote access IP address as well as restrict the listening interface. If this option is not specified connections will be accepted on any interface.
  - <typewriter>-p#</typewriter>
    Allows the base TCP port to be specified (default: 13100). The server utilizes three (3) TCP ports starting with the specified base port (e.g., 13100,13101 and 13102). The ports utilized are logged by the server during startup.
  - <typewriter>-n</typewriter>
    Enables reverse name lookup for IP addresses when logging (requires proper configuration of reverse lookup by your DNS server). Please note that logging of host names is now disabled by default due to the slow-down which occurs when reverse DNS is not properly configured on the network.
- Authentication options
  - <typewriter>-a#</typewriter>
    Allows a user authentication mode to be specified (see User Authentication)
  - <typewriter>-d<ad_domain></typewriter>
    Sets the Active Directory domain name. Example: "-dmydomain.com"
  - <typewriter>-e#</typewriter>
    Allows the reset password expiration to be set to a specified number of days (default is 1-day). A value of 0 prevents expiration.
  - <typewriter>-jaas <config_file></typewriter>
    Specifies the path to the JAAS config file (when using -a4), relative to the ghidra/server directory (if not absolute).

    See jaas.conf for examples and suggestions. It is the system administrator's responsibility to craft their own JAAS configuration directive when using the -a4 mode.

  - <typewriter>-u</typewriter>
    Allows the server login user ID to be specified at time of login for <typewriter>-a0</typewriter> authentication mode. Without this option, the users client-side login ID will be assumed.
  - <typewriter>-autoProvision</typewriter>
    Enable the auto-creation of new Ghidra Server users when they successfully authenticate to the server (-a1 and -a4 modes only). Users removed from the authentication provider (e.g., Active Directory) will need to be deleted manually from the Ghidra Server using svrAdmin command.
  - <typewriter>-anonymous</typewriter>
    Enable anonymous access support for Ghidra Server and its repositories. Only those repositories which specifically enable anonymous access will be accessible as read-only to an anonymous user.
  - <typewriter>-ssh</typewriter>
    Enable SSH as an alternate form of authentication when using <typewriter>-a0</typewriter> authentication mode.

(Back to Top)

## Running Ghidra Server on Microsoft Windows

### Server Scripts (located within the server subdirectory)

- <typewriter>svrInstall.bat</typewriter>
  installs server as service (<typewriter>ghidraSvr</typewriter>)
- <typewriter>svrUninstall.bat</typewriter>
  removes previously installed server service
- <typewriter>svrAdmin.bat</typewriter>
  facilitates Ghidra Server administrative commands (see Server Administration)
- <typewriter>ghidraSvr.bat</typewriter>
  provides a variety of commands for controlling the server when running as a daemon process. When running this script it accepts a single argument which is one of the following commands. Many of these commands are included so that this script may be used for controlling the service.

- <typewriter>console</typewriter>
  starts server within the current terminal window. <typewriter>console</typewriter> argument may be omitted to allow for double-click execution in this mode.
- <typewriter>start</typewriter>
  starts the previously installed Ghidra Server service
- <typewriter>stop</typewriter>
  stops the installed Ghidra Server service which is currently running
- <typewriter>restart</typewriter>
  stops and restarts the previously installed Ghidra Server service
- <typewriter>status</typewriter>
  displays the current status of the Ghidra Server (<typewriter>ghidraSvr</typewriter>) service

NOTE: The above scripts may be run from a <typewriter>CMD</typewriter> window, or by double-clicking the script file from an Explorer window. Other than the console and status operation, elevated privilege is needed to run these commands. As such the user executing these scripts must be a member of the Administrator group and must be run with elevated privilege. If using Windows Vista or newer, the best way to accomplish this is to run the <typewriter>CMD</typewriter> shell using the <typewriter>Run as Administrator</typewriter> action which is available by right-clicking on a command shortcut or batch file. If the <typewriter>CMD</typewriter> shell is run in this manner, the Ghidra Server scripts may then be executed within the shell to run with administrator privilege.

### Running Server in Console Window (intended for diagnostic use only)

NOTE: Starting the server in console mode is generally intended for diagnostic use only. Extreme care must be taken to ensure that any user who starts the Ghidra Server via this script has full access to all directories and files within the root repository directory.
If the Ghidra Server is not already running, it may be started within a console window by running the <typewriter>ghidraSvr.bat console</typewriter> command. When you wish to terminate the server, use the <typewriter>Ctrl-C</typewriter> key sequence within the server console window and wait for a clean shutdown.

### Install as Automatic Service (must have Administrator privilege)

The Ghidra Server may be installed as an automatic service by executing the <typewriter>svrInstall.bat</typewriter> script. This script may be run from a <typewriter>CMD</typewriter> window, or by double-clicking the script file from an Explorer window. Once installed, the server will start automatically when the system is booted. Immediately after running this script the service will not be running, you will need to either reboot or start the service from the Service Control Panel.

### Uninstall Service (must have Administrator privilege)

If after installing the Ghidra Server as a service you wish to uninstall it, you may run the <typewriter>svrUninstall.bat</typewriter> script. You must stop the service via the Service Control Panel prior to running this script. This script may be run from a <typewriter>CMD</typewriter> window, or by double-clicking the script file from an Explorer window.

NOTE: It is very important that you uninstall the service prior to doing any of the following activities:

- deleting or upgrading the Ghidra installation
- moving/renaming the Ghidra installation directory

(Back to Top)

## Running Ghidra Server on Linux or Mac-OSX

### Server Scripts (located within the server subdirectory)

- <typewriter>svrInstall</typewriter>
  installs server as service (<typewriter>ghidraSvr</typewriter> or <typewriter>wrapper.ghidraSvr</typewriter>)
- <typewriter>svrUninstall</typewriter>
  removes previously installed server service
- <typewriter>svrAdmin</typewriter>
  facilitates administrative commands (see Server Administration)
- <typewriter>ghidraSvr</typewriter>
  provides a variety of commands for controlling the server when running as a daemon process. When running this script it accepts a single argument which is one of the following commands. Many of these commands are included so that this script may be used for controlling the service.
- <typewriter>console</typewriter>
  starts server within the current terminal window
- <typewriter>start</typewriter>
  starts the previously installed Ghidra Server service
- <typewriter>stop</typewriter>
  stops the installed Ghidra Server service which is currently running
- <typewriter>restart</typewriter>
  stops and restarts the previously installed Ghidra Server service
- <typewriter>status</typewriter>
  displays the current status of the Ghidra Server (<typewriter>ghidraSvr</typewriter>) service

### Running Server in Console Window

NOTE: Starting the server in console mode is generally intended for diagnostic use only. Care must be taken to ensure that any user who starts the Ghidra Server via this script has full access to all directories and files within the root repository directory.

If the Ghidra Server is not already running, it may be started within a terminal window by running the command: <typewriter>ghidraSvr console</typewriter>. When you wish to terminate the server, use the <typewriter>Ctrl-C</typewriter> key sequence within the server console window and wait for a clean shutdown.

### Install as Automatic Service (must have admin privilege)

The Ghidra Server may be installed as an automatic service by executing the <typewriter>svrInstall</typewriter> script. Once installed, the server will start automatically when the system is booted.

If it is preferred to run the service with a dedicated local user account, the following entry may be added to the server.conf file with the appropriate account specified in place of <uid>. A dedicated local service account should generally be a no-login account with a corresponding group identifier with the same name (i.e., see /etc/passwd and /etc/group). The local account should be established and specified with server.conf prior to installation of the Ghidra Server service.

    	wrapper.app.account=<uid>

It is also important that the repositories directory and Ghidra installation files be owned by the service account with proper permissions. Note that while the Ghidra Server Java process will run using the specified uid the wrapper process will continue to run as root and monitor/manage the Java process.

### Uninstall Service (must have admin privilege)

If after installing the Ghidra Server as a service you wish to uninstall it, you may run the <typewriter>svrUninstall</typewriter> script.

NOTE: It is very important that you uninstall the service prior to doing any of the following activities:

- deleting or upgrading the Ghidra installation
- moving/renaming the Ghidra installation directory

(Back to Top)

## Server Administration

The script <typewriter>svrAdmin</typewriter>, or <typewriter>svrAdmin.bat</typewriter>, provides the ability to manage Ghidra Server users and repositories. This script must be run from a command shell so that the proper command line arguments may be specified.

The general command usage is:

        svrAdmin [<server-root-path>]
                 [-add <user_sid> [--p]]
                 [-remove <user_sid>]
                 [-reset <user_sid> [--p]]
                 [-dn <user_sid> "<user_dn>"]
                 [-admin <user_sid> "<repository_name>"]
                 [-list]
                 [-users]
                 [-migrate-all]
                 [-migrate "<repository_name>"]

- <typewriter><server-root-path></typewriter>
  There is normally no need to specify this argument on the command line. The default server-root-path is determined by the server.conf setting of the 'ghidra.repositories.dir' variable. This allows both the server execution and <typewriter>svrAdmin</typewriter> script to utilize the same setting.
- <typewriter>-add</typewriter> (Adding a User)
  All authentication modes require that a user first be added to the server for a connection to be permitted. If Ghidra password authentication is used [<typewriter>-a0</typewriter>], the initial password is set to <typewriter>changeme</typewriter>. This password must be changed by the user within 24-hours to avoid its expiration (password expiration period can be extended as a server option, see <typewriter>-e</typewriter> server option). Alternatively, the initial password may be specified by including the optional <typewriter>--p</typewriter> parameter which will prompt for an initial password.
  Examples:

              svrAdmin -add mySID
              svrAdmin -add mySID --p

- <typewriter>-remove</typewriter> (Removing a User)
  A user may be removed from the server with this command form. This will only prevent the specified user from connecting to the server and will have no effect on the state or history of repository files. If a repository admin wishes to clear a user's checkouts, this is a separate task which may be performed from an admin's Ghidra client.
  Example:

              svrAdmin -remove mySID

- <typewriter>-reset</typewriter> (Reset User's Ghidra Password)
  If a user's password has expired, or has simply been forgotten, the password may be reset to <typewriter>changeme</typewriter>. After resetting, this password must be changed by the user within 24-hours to avoid its expiration (password expiration period can be extended as a server option). Alternatively, the new password may be specified by including the optional <typewriter>--p</typewriter> parameter which will prompt for an initial password.
  Example:

              svrAdmin -reset mySID
              svrAdmin -reset mySID --p

- <typewriter>-dn</typewriter> (Assign User's Distinguished Name)
  The use of PKI authentication requires that each user's DN be associated with their user SID.
  Example:

              svrAdmin -dn mySID "CN=MyName,OU=AGENCY,OU=DoD,O=U.S. Government,C=US"

  NOTE: After having been added to the server, a user's DN may be copied from the <typewriter>UnknownDN.log</typewriter> file following an attempted connection with their PKCS certificate.
- <typewriter>-admin</typewriter> (Adding a Repository Administrator)
  If an existing repository administrator is unable to add another user as administrator, the server administrator may use this command to specify a new repository administrator.
  Example:

              svrAdmin -admin mySID "myProject"

- <typewriter>-list</typewriter> (List All Repositories)
  Lists all repositories. If the -users option is also present, the user access list will be included for each repository.
  Example:

              svrAdmin -list

- <typewriter>-users</typewriter> (List All Users)
  Lists all users with server access. May also be coupled with the -list option.
  Example:

              svrAdmin -users

- <typewriter>-migrate-all</typewriter> (Migrate All Repositories to Use Indexed File-System Storage)
  For all repositories which are using the deprecated Mangled Filesystem storage, they will be marked for migration to the Indexed Filesystem storage with support for longer file pathnames. The actual migration will be performed when the Ghidra Server is restarted.
  Please note that any migration to the Indexed filesystem storage is a one-way conversion so a backup of your server repositories directory is highly recommended before proceeding.
  Example:

              svrAdmin -migrate-all

- <typewriter>-migrate</typewriter> (Migrate a Specified Repository to use Indexed File-System Storage)
  The specified repository will be marked for migration to the Indexed Filesystem storage with support for longer file pathnames. The actual migration will be performed when the Ghidra Server is restarted.
  Please note that any migration to the Indexed filesystem storage is a one-way conversion so a backup of your server repositories directory is highly recommended before proceeding.
  Example:

              svrAdmin -migrate "myProject"

(Back to Top)

## Repository Backup

As with any server, it is highly recommended that your server repositories directory be periodically backed-up or whenever an upgrade (or data migration) is performed. While backups may be taken while the Ghidra Server is idle (e.g., after midnight), it is always safest to stop the Ghidra Server while a backup is in progress.

(Back to Top)

## Clearing Obsolete Checkouts

Any user who has Admin privilege of a specific repository may use the Ghidra client to View Checkouts for a specific file and Delete individual checkouts from those that are listed. The <typewriter>View Checkouts</typewriter> action is available from the popup-menu of the Ghidra Project Window by right-clicking on a specific project file.

Under special circumstances (e.g., classroom environment) it may be desirable to remove all checkouts either for a specific repository or an entire Ghidra Server. Under Linux/Mac this is most easily accomplished from the command shell while the Ghidra Server is stopped. The following command may be used:

        find <repo-path> -name checkout.dat -exec rm {} \;

where <typewriter><repo-path></typewriter> is the directory path of a specific named repository root, or the parent repositories directory if clearing checkouts for all repositories.
WARNING! Since the <typewriter>find</typewriter> command is recursive, care must be taken when specifying the <typewriter><repo-path></typewriter> and the other parameters. If you specify the incorrect <typewriter><repo-path></typewriter> or omit the correct <typewriter>-name</typewriter> argument, you may remove important files without the ability to recover. (Back to Top)

## PKI Certificates

PKI keys/certificates can be used to authenticate clients and/or servers. When using the Ghidra Server PKI authentication mode this corresponds to "client authentication" which requires the <typewriter>server.conf</typewriter> to specify a <typewriter>cacerts</typewriter> file location and each user client to configure a user signing key/certificate keystore file. If clients wish to authenticate the server, the <typewriter>server.conf</typewriter> must specify a server key/certificate keystore file and each user client must configure a <typewriter>cacerts</typewriter> file. See Managing PKI Certificate Authorities for more information on configuring a <typewriter>cacerts</typewriter> file.

User and server certificates must be acquired through one of many trusted authorities identified by the <typewriter>cacerts</typewriter> file installed by the peer system. Your network support staff should be able to help you acquire a suitable signing key/certificate in the form of either a <typewriter>*.p12, *.pks,</typewriter> or <typewriter>*.pfx</typewriter> file.

User's of the Ghidra GUI application can install their key/certificate file via the project window menu item Edit->Set PKI Certificate.... The user will be prompted for their keystore password the first time key access is required for a network connection after starting the application. If using the <typewriter>analyzeHeadless</typewriter> script, see the <typewriter>analyzeHeadlessREADME.html</typewriter> file for details.

If the Ghidra Server will be installing a server certificate, the <typewriter>server.conf</typewriter> file should be modified to properly identify the server's key/certificate location (ghidra.keystore) and password (ghidra.password).

(Back to Top)

## Managing PKI Certificate Authorities

When utilizing PKI authentication for a Ghidra Server a set of certificates for trusted Certificate Authorities (CA) must be collected and added to a cacerts keystore file created using the Java keytool. The Java keytool can be found within the Java Development Kit (JDK) provided with Ghidra (<typewriter>java/bin/keytool</typewriter>) or any other Java distribution. The default cacerts keystore file location is <typewriter>Ghidra/cacerts</typewriter> and is also specified by the <typewriter>ghidra.cacerts</typewriter> property setting within the <typewriter>server.conf</typewriter> file. Uncomment this specification within the <typewriter>server.conf</typewriter> file to activate use of the <typewriter>cacerts</typewriter> for all incoming SSL/TLS connections (i.e., all Ghidra client users must install and employ the use of their personal PKI signing certificate for both headed and headless use - see PKI Certificates). Clients can also impose server authentication for all HTTPS and Ghidra Server connections by creating the <typewriter>cacerts</typewriter> file and enabling the <typewriter>ghidra.cacerts</typewriter> property setting within the support/launch.sh and/or launch.bat scripts.

Individual CA public key certificates should be obtained in a Base64 encoding (see sample below). If pasting the encoded certificate into a file, be sure to include an extra blank line after the END CERTIFICATE line.

Sample Base64 encoded certificate:

    -----BEGIN CERTIFICATE-----
    laSKCIElkjsudCUDusjSUkjeMSUjAJHDuLQWMCMausALkKXMXOOjSKSUjssjSKAA
    ksDSDjLKJHAuemCXXUmxxqjaskuDSYRmxiqgDlakkUSUdhemjASKUakjhuEhxMSD
    ...
    ksJKDwocQwyeEIcbzHtyrSLfoeyGCmvbNLGHpgoruSTYQafzDFTgwjkJHCXVDjdg
    KDowiyYTXkcuiwCJXuyqCHpdoORriwwcCWUskucuwHDJskuejdkUWJCUDSjujsUE
    -----END CERTIFICATE-----

You can inspect the contents of a Base64 encoded certificate file with the following command:

        keytool -printcert -v -file <base64file>

where:

- <typewriter><base64file></typewriter> is the file containing the Base64 encoded CA certificate to be imported.

The Owner common name (CN) displayed by this command should be used as the alias when importing the certificate into your cacerts file.
The following command should be used to add a CA certificate to a new or existing cacerts file:

        keytool -import -alias "<caAlias>" -file <base64file> -storetype jks -keystore <cacerts-file>

where:

- <typewriter><caAlias></typewriter> is the name of the CA corresponding to the imported certificate.
- <typewriter><base64file></typewriter> is the file containing the Base64 encoded CA certificate to be imported.
- <typewriter><cacerts-file></typewriter> is the cacerts file to be used by the Ghidra Server (and/or client if needed).

The keystore password will be requested and is used to restrict future modifications to the <typewriter>cacerts</typewriter> file.
When starting the Ghidra Server with PKI authentication enabled, the CA certificates contained within the <typewriter>cacerts</typewriter> file will be dumped to the log with their expiration dates.

Please note that the Ghidra Server does not currently support Certificate Revocation Lists (CRLs).

(Back to Top)

## Upgrading the Ghidra Server Installation

1. Be sure to backup your projects and tools to ensure that the new Ghidra installation does not overwrite any of your data. Individual program files upgraded to a newer version of Ghidra can not be opened with an older version.
2. Uninstall an installed Ghidra Server Service by following the <typewriter>Uninstall Service</typewriter> instructions corresponding to your operating system (Windows or Linux/Mac-OSX).
3. Unzip the new Ghidra distribution to a new installation directory (general unpacking and installation guidelines may be found in <typewriter>ghidra_x.x/docs/InstallationGuide.html</typewriter>).
4. Copy the old <typewriter>repositories</typewriter> directory to the new Ghidra Server installation directory.
5. Copy the <typewriter>wrapper.app.parameter.#</typewriter> lines from your old <typewriter>server/server.conf</typewriter> file to the new installation <typewriter>server/server.conf</typewriter>. For 5.0 release and earlier, your old <typewriter>server.conf</typewriter> file is located within a platform-specific directory (<typewriter>core/os/<platform></typewriter>). No other changes should be made to your new <typewriter>server.conf</typewriter> file.
   Do not replace the new <typewriter>server.conf</typewriter> file with your old <typewriter>server.conf</typewriter> file, as this could cause server problems.
6. If desired, install the Ghidra Server Service from the new installation server subdirectory by following the instructions corresponding to your operating system (Windows or Linux/Mac-OSX).

WARNING! As of Ghidra 7.0 a new project/server storage implementation, <typewriter>Indexed-V1</typewriter>, has been added which is not compatible with older versions of Ghidra. The <typewriter>Indexed-V0</typewriter> filesystem storage allows longer filenames and paths to exist within a project, while the <typewriter>V1</typewriter> version expands support to facilitate some of the very large project/repository features introduced in Ghidra 7.0. Since the legacy storage implementation (<typewriter>Mangled</typewriter>) used by older projects and repositories is still supported, conflicting storage behavior may exist between a Ghidra project and its server repository for long filename/path support. It is highly recommended that all server repositories and associated projects be migrated to the new Indexed storage implementation in a coordinated fashion after making a complete backup. All new Ghidra projects will utilize the new Indexed storage implementation, so care should taken when creating shared projects with older repositories.

NOTE: If using Ghidra 6.0.x, opening a project which uses the newer <typewriter>Indexed-V1</typewriter> filesystem may cause the project storage to revert to the older <typewriter>Indexed-V0</typewriter> filesystem.

A user may determine which storage implementation is used by a project by viewing the <typewriter>Project Info</typewriter> display (via <typewriter>Project</typewriter> -> <typewriter>View Project Info...</typewriter>). Local projects using the legacy <typewriter>Mangled</typewriter> filesystem may be migrated to the new <typewriter>Indexed</typewriter> filesystem via this <typewriter>Project Info</typewriter> panel. The status of Ghidra Server repositories storage can be determined and flagged for migration via the <typewriter>server/svrAdmin</typewriter> script (described in the Server Administration section). Please note that any migration to the <typewriter>Indexed</typewriter> filesystem storage is a one-way conversion so a backup of your project or server repositories directory is highly recommended before proceeding.

(Back to Top)

## Troubleshooting

### Failures Creating Repository Folders / Checking in Files

If you see continuous failures to create repository folders or failures to check in files, check the disk space on the server or folder permissions. When the server runs out of disk space, it cannot create folders or check in files.

### Client/Server connection errors

The Ghidra Server has transitioned to using SSL/TLS connections when accessing the server's RMI registry. This change in communication protocol can cause unexpected symptoms when attempting to connect incompatible versions of Ghidra. When an older incompatible Ghidra client attempts to access a newer SSL/TLS enabled Ghidra Server registry, the following connection error will occur:

    	non-JRMP server at remote endpoint

### MS Windows - ERROR Missing Temp Directory

Running the Ghidra Server as an installed service under Windows may attempt to use a non-existing temporary directory (e.g., <typewriter>C:\Windows\system32\config\systemprofile\AppData\Local\Temp\</typewriter>). The work-around for this is to configure the server to use an existing temporary directory (e.g., <typewriter>C:\Windows\Temp</typewriter>). This can be done by editing the <typewriter>server.conf</typewriter> file, locate the <typewriter>wrapper.java.additional</typewriter> entries and add/uncomment an entry with your temporary directory specified. For example:

        wrapper.java.additional.3=-Djava.io.tmpdir=C:\Windows\Temp

Be sure to use the next unique sequence number for your <typewriter>wrapper.java.additional</typewriter> entry.

### MS Windows 7 and 8 - <typewriter>ghidraSvr.bat</typewriter>, <typewriter>svrInstall.bat</typewriter>, or <typewriter>svrUninstall.bat</typewriter> Error

The following error may occur when attempting to install/uninstall/start/stop/restart the Ghidra Server under MS Windows 7 or 8 even if the user is a member of the Administrator group:

        Access denied: please check the user credentials

The user executing these scripts must be a member of the Administrator group and must be run with elevated privilege. The best way to accomplish this is to run the <typewriter>CMD</typewriter> shell using the <typewriter>Run as Administrator</typewriter> action which is available by right-clicking on a command shortcut or batch file. If the <typewriter>CMD</typewriter> shell is run in this manner, the Ghidra Server scripts may then be executed within the shell to run with administrator privilege. Failure to run the scripts in this manner may cause failure information to be hidden from view due to the privilege escalation mechanism.

### Linux - SELinux must be disabled

The Ghidra Server may not start properly if SELinux has not been disabled. This setting is specified in the file <typewriter>/etc/selinux/config</typewriter>.

### Linux - Potential hang from /dev/random depletion

SSL communications and the PKI/SSH authentication mechanisms employed by GHIDRA make use of the Java SecureRandom class to generate random numbers required by various cryptographic techniques. On Linux systems this class makes use of /dev/random to produce these random numbers which in turn relies on other system entropy sources to feed it. We have seen that /dev/random can become depleted which can cause the dependent Java application to hang. While Java claims to have settings which should allow /dev/urandom to be used, these security settings do not appear to work as intended. The best workaround we have found for systems which exhibit this problem is to install haveged (HArdware Volatile Entropy Gathering and Expansion Daemon) which will satisfy the entropy demand needed by /dev/random.

(Back to Top)