The cluster secret must be exactly 64 characters and contain only hexadecimal characters (
[0-9a-f]). (from "cluster_config.go" | ipfs-cluster @ GitHub)
So, we just need to generate a 64 character in hex.
$ od -vN 32 -An -tx1 /dev/urandom | tr -d ' \n'
902e6adde605ce06ad8881a5b9f6bc022e112ad739f6b8b2f76618791b878790export CLUSTER_SECRET=$(od -vN 32 -An -tx1 /dev/urandom | tr -d ' \n')
echo $CLUSTER_SECRETAs a reference, in the source code, it uses cryptographically secure random numbers.
// Default fills in all the Config fields with
// default working values. This means, it will
// generate a Secret.
func (cfg *Config) Default() error {
cfg.setDefaults()
clusterSecret := make([]byte, 32)
n, err := rand.Read(clusterSecret)
if err != nil {
return err
}
if n != 32 {
return errors.New("did not generate 32-byte secret")
}
cfg.Secret = clusterSecret
return nil
}- cluster_config.go#L211-L225 @ GitHub