Description
In case you accidentally overwrote the only copy of the AES-encoded passkey file with another passkey file, you may see the following error message in the server logs:
java.security.GeneralSecurityException: Couldn't decrypt password; the decryption key is likely invalid. This usually means the server passkey file used to encrypt the password has changed and cannot be used to decrypt the password. If you full exported data from one machine and full imported it to another, then encrypted passwords cannot be accessed on the new machine unless you also copy the server passkey file across at the same time. at com.electriccloud.crypto.PasswordCrypterImpl.decrypt(PasswordCrypterImpl.java:234) at com.electriccloud.security.SessionManagerImpl.decryptSecretId(SessionManagerImpl.java:525) at com.electriccloud.security.SessionManagerImpl.deleteSessionEntity(SessionManagerImpl.java:1420) at com.electriccloud.security.SessionManagerImpl.deleteSession(SessionManagerImpl.java:617)
Workaround
In case you accidentally overwrote the only copy of the passkey and do not have another instance of the file backed up elsewhere, either on another server or, for clustered configurations, in Zookeeper, the only option you have is to regenerate the passkey manually using the following steps. Following are recovery instructions for both Standalone configurations and Clustered configurations.
Standalone configurations
-
Delete or rename the passkey file at
<DATA_DIR>/conf/passkey. -
Change
COMMANDER_DB_PASSWORDto plain text in<DATA_DIR>/conf/database.properties. -
Start the CloudBees CD/RO server and sign in to the UI. This generates a new
passkeyfile and encrypts theCOMMANDER_DB_PASSWORDin the<DATA_DIR>/conffolder using the new AES-256 passkey. -
Stop the CloudBees CD/RO server.
-
Now, sign in to the CloudBees CD/RO UI and manually update the passwords that you saved:
-
Any credentials you created
-
Passwords for email configuration
-
DirectoryProvider passwords
-
Analytics configuration password
You are not able to change the SessionIDpasswords used at runtime for job steps. So you need to rerun those jobs.
-
-
As a best practice, back up the new working AES 256
passkeyanddatabase.properties.
Clustered configurations
-
Identify the machine you need to work on and shut down the other machines in the CloudBees CD/RO cluster.
-
Download
database.properties,keystore,passkey, andcommander.propertiesconfiguration files from ZooKeeper.cd <install-dir>/conf <install-dir>/jre/bin/java \ -DCOMMANDER_ZK_CONNECTION=<zooKeeper-server:port> \ -jar <install-dir>/server/bin/zk-config-tool-jar-with-dependencies.jar \ com.electriccloud.commander.zkconfig.ZKConfigTool \ --readFile /commander/conf/database.properties database.properties <install-dir>/jre/bin/java \ -DCOMMANDER_ZK_CONNECTION=<zooKeeper-server:port> \ -jar <install-dir>/server/bin/zk-config-tool-jar-with-dependencies.jar \ com.electriccloud.commander.zkconfig.ZKConfigTool \ --readFile /commander/conf/passkey passkey <install-dir>/jre/bin/java \ -DCOMMANDER_ZK_CONNECTION=<zooKeeper-server:port> \ -jar <install-dir>/server/bin/zk-config-tool-jar-with-dependencies.jar \ com.electriccloud.commander.zkconfig.ZKConfigTool \ --readFile /commander/conf/keystore keystore <install-dir>/jre/bin/java \ -DCOMMANDER_ZK_CONNECTION=<zooKeeper-server:port> \ -jar <install-dir>/server/bin/zk-config-tool-jar-with-dependencies.jar \ com.electriccloud.commander.zkconfig.ZKConfigTool \ --readFile /commander/conf/commander.properties commander.properties -
Switch CloudBees CD/RO from cluster mode to standalone mode.
-
To the end of
<DATA_DIR>/conf/wrapper.conffile add the following lines:wrapper.java.additional.261=-DCOMMANDER_IGNORE_SERVER_MISMATCH=1 wrapper.java.additional.262=-DCOMMANDER_IGNORE_PASSKEY_MISMATCH=1Ensure that the numbers 261and262are unique within the file. If not, change the number to a unique value. -
Run the
ecconfigurecommand to set it to single/standalone mode:ecconfigure --serverEnableClusteredMode=0 --skipServiceRestart
-
-
Delete the current pass key in the
<DATA_DIR>/conf/passkeyfile. -
Change
COMMANDER_DB_PASSWORDto plain text in<DATA_DIR>/conf/database.properties. -
Start the CloudBees CD/RO server and sign in to the UI. This generates a new
passkeyfile and encrypts theCOMMANDER_DB_PASSWORDin the<DATA_DIR>/conf/database.propertiesfile using the new AES-256 passkey. -
Stop the CloudBees CD/RO server.
-
Push the new
passkeyanddatabase.propertiesto Zookeeper.cd <install-dir>/conf <install-dir>/jre/bin/java \ -DCOMMANDER_ZK_CONNECTION=<zooKeeper-server1-ip> \ -jar <install-dir>/server/bin/zk-config-tool-jar-with-dependencies.jar com.electriccloud.commander.zkconfig.ZKConfigTool \ --databasePropertiesFile database.properties \ --passkeyFile passkeyUse COMMANDER_ZK_CONNECTIONfrom your<DATA_DIR>/conf/wrapper.conffile. -
Switch the CloudBees CD/RO environment back to cluster mode:
ecconfigure --serverEnableClusteredMode=1 --skipServiceRestart -
Start the CloudBees CD/RO server.
-
Download the new working AES-256
passkeyanddatabase.propertiesfrom Zookeeper and back them up for safe keeping.<install-dir>/jre/bin/java \ -DCOMMANDER_ZK_CONNECTION=<zooKeeper-server1-ip> \ -jar <install-dir>/server/bin/zk-config-tool-jar-with-dependencies.jar com.electriccloud.commander.zkconfig.ZKConfigTool \ --readFile /commander/conf/database.properties mynew92_aes256_database.properties <install-dir>/jre/bin/java \ -DCOMMANDER_ZK_CONNECTION=<zooKeeper-server1-ip> -jar \ /opt/cloudbees/sda/server/bin/zk-config-tool-jar-with-dependencies.jar com.electriccloud.commander.zkconfig.ZKConfigTool \ --readFile /commander/conf/passkey mynew92_aes256_passkey -
Remove the lines you added previously to the end of the
<DATA_DIR>/conf/wrapper.conffile:wrapper.java.additional.261=-DCOMMANDER_IGNORE_SERVER_MISMATCH=1 wrapper.java.additional.262=-DCOMMANDER_IGNORE_PASSKEY_MISMATCH=1 -
Now, sign in to the CloudBees CD/RO UI and manually update the passwords that you saved:
-
Any credentials you created
-
Passwords for email configuration
-
DirectoryProvider passwords
-
Analytics configuration password
You are not able to change the SessionIDpasswords used at runtime for job steps, so you need to rerun those jobs.
-
-
Start up the other CloudBees CD/RO servers in the cluster.