google-templatescassandra

Modify the default administrator password

Change the Cassandra root password

You can modify the Cassandra password using the following command at the shell prompt:

$ cqlsh -u cassandra -p USERPASSWORD
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.9 | CQL spec 3.4.2 | Native protocol v4]
Use HELP for help.

cqlsh> ALTER USER cassandra WITH PASSWORD 'NEWPASSWORD';
cqlsh> exit

Remember to replace USERPASSWORD in the previous commands with your current password and NEWPASSWORD with the new password.

Reset the Cassandra root password

If you don’t remember your Cassandra root password, you can follow the steps below to reset it to a new value:

  • Edit the /opt/bitnami/cassandra/conf/cassandra.yaml file and replace the following lines:

      authenticator: PasswordAuthenticator
      authorizer: CassandraAuthorizer
    

    with:

      authenticator: AllowAllAuthenticator
      authorizer: AllowAllAuthorizer
    
  • Restart your database:

      $ sudo service bitnami restart
    
  • Execute the following commands:

      $ cqlsh
      Connected to Test Cluster at 127.0.0.1:9042.
      [cqlsh 5.0.1 | Cassandra 3.9 | CQL spec 3.4.2 | Native protocol v4]
      Use HELP for help.
    
      cqlsh> UPDATE system_auth.roles SET salted_hash = '$2a$10$1gMPBy9zSkDzKxdbU2v/gOslcMRPDcXVqmwQYBmi8MVgYvNdRZw/.' WHERE role = 'cassandra';
      cqlsh> exit
    

    NOTE: '$2a$10$1gMPBy9zSkDzKxdbU2v/gOslcMRPDcXVqmwQYBmi8MVgYvNdRZw/.' is the output of applying the salted_hash function to the string cassandra.

  • Re-enable the authentication. Undo the changes made in the /opt/bitnami/conf/cassandra.yaml file. Replace the following lines:

      authenticator: AllowAllAuthenticator
      authorizer: AllowAllAuthorizer
    

    with:

      authenticator: PasswordAuthenticator
      authorizer: CassandraAuthorizer
    
  • Now you can access your database using the username cassandra and password cassandra:

      $ cqlsh -u cassandra -p cassandra
    

    NOTE: Don’t forget to change the cassandra user account password. This is the default password and it’s unsecure.

Last modification December 31, 2018