Since version 4, NoMachine servers support three different authentication methods:
1) Login with NX protocol and system login
Connection is via the NX protocol, the user authenticates on the system. Password and key-based authentication and two-factor authentication methods are supported.
How to set up key based authentication with NX protocol:
2) Login with SSH protocol and system login (not available with NoMachine free)
Connection is via the SSH protocol, the user authenticates on the system. Password, key-based authentication, Kerberos ticket-based and two-factor authentication methods are supported.
3) Login with SSH protocol and NoMachine login (not available with NoMachine free)
Connection is via the SSH protocol, the client first authenticates as user nx by using an SSH key pair and then the user authenticates on the system (only password authentication and two-factor authentication methods are supported).
This article deals with case 3) and explains how to replace the default SSH key pair for the nx user.
The custom SSH key pair has to be generated on the server and the new private key has to be distributed to clients to let them connect to the server.
For more information about keys and certificates for host verification used by NoMachine and how to replace them:
How to replace the default SSH key pair for the NoMachine login
Generate a custom SSH key pair
1) On the NoMachine server host machine run from xterm or CMD shell on Windows:
IMPORTANT: This command generates a new RSA and DSA pair of keys. Since NoMachine v. 5.1.22 client and server uses by default the RSA key pair. Older versions of client still requires the DSA key.
The private part from the newly generated RSA pair of keys is:
and of the new DSA key pair:
where BaseDirectory is the installation directory of the NoMachine software (by default, /usr/NX on Linux, /Applications/NoMachine.app/Contents/Frameworks/ on Mac OS X and c:/Program Files/NoMachine on Windows).
The private key has to be distributed to all clients that have to be granted access to the server host.
If the NoMachine client is v. 5.1.22 or later, distribute the server.id_rsa.key key.
If it is an older version 5 or it's version 4, distribute the server.id_dsa.key.
Distribute the new SSH private key to clients
1) Place the new key server.id_rsa.key (or server.id_dsa.key for older clients) under the subdirectory 'share/keys' of the NoMachine installation tree.
2) To use the new key for a specific session, access the configuration panel for that session and select the SSH protocol. Then open 'Advanced' settings, select the 'Use the NoMachine login' and continue. You can specify there the alternative key to be used for that session only.
3) To use the new SSH key for all the sessions (except those sessions that have been previously configured to use a specific key), rename the original private key (e.g. on Linux: BaseDirectory/NX/share/keys/server.id_rsa.key or BaseDirectory/NX/share/keys/server.id_dsa.key) to preserve it and put in place the new private key.
Use the new SSH private key for web sessions
To let the Cloud Server (webplayer) use the new private key, it's necessary to specify location and file name of the DSA key in the BaseDirectory/etc/cloud.cfg configuration file by setting a proper value for the following key:
Notes for NX 3.5.0 version
Generate a custom SSH key pair for connecting to the NX Server
1) On the NX Server host generate the new SSH key pair by running:
2) Change ownership and permissions on the authorized_keys file:
chown nx:root /usr/NX/home/nx/.ssh/authorized_keys2
chmod 0644 /usr/NX/home/nx/.ssh/authorized_key2
chown nx:root /usr/NX/home/nx/.ssh/authorized_keys
chmod 0644 /usr/NX/home/nx/.ssh/authorized_keys
3) Change ownership and permissions on the following file:
chown nx:root /usr/NX/home/nx/.ssh/default.id_dsa.pub
chmod 0644 /usr/NX/home/nx/.ssh/default.id_dsa.pub
4) Distribute the private key to all clients that need to connect to that NX server.
The private key that must be distributed to clients is:
Distribute the new SSH key to NX Clients
4.1) Place the new key under the subdirectory 'share/keys' of the NX Client installation tree on the end-user's machine.
(/usr/NX/share/keys on MacOS/X, Linux and Solaris, C:Program FilesNX Client for Windowssharekeys on Windows)
4.2) Load the new SSH from the NX Client 3.5.0 GUI: from the 'General' tab of the session configuration window, click on the 'Key' button and choose 'Import' to import the new key by navigating to the appropriate directory above and Save to save your changes. The new key will be used only for the session you are configuring.
To use the new SSH key as default for all sessions:
- Rename the original private key ( /usr/NX/share/keys/server.id_dsa.key) distributed togheter with the client installation.
- Rename the new private key from:
In this way, the new key will be used as the default key for all NX sessions (except those sessions that have been previously configured
to use a specific key).
Use the new SSH key with the NX Server Manager
Specify location and file name of the new key in the /usr/NX/etc/manager.cfg configuration file and set a proper value for the NXSSHPathIdentity key.
Restore the default SSH key pair
Run the following command to restore the SSH key pair provided with the server package:
The current public key will be moved to default.id_dsa.pub.backup file, while the current private key will be moved to /usr/NX/share/keys/default.id_dsa.key.backup file. Run the following command to use the default SSH key-pair:
To restore the default SSH key in the client, use the key management facilities provided by the NX Client GUI: in the 'General' tab of the session configuration window, click on the 'Key' button and choose Default. Click Save to save your changes.