Can I generate Rails SECRET_KEY_BASE without Ruby?
Asked Answered
T

1

10

I'm wondering if there is a way to generate a Rails SECRET_KEY_BASE variable without having Ruby installed? All answers on SO I've seen point to using the SecureRandom library in Ruby.

This is fine, but my situation is a bit chicken and egg - I want to generate a file with a SECRET_KEY_BASE before I've built a Docker image with my Rails app. The base VM that the container runs in doesn't have Ruby installed.

It's Ubuntu 16.04 server and I'd install as little extra as possible (preferably just Docker!). It has Perl and OpenSSL installed. Could any of these be used?

Telestich answered 29/5, 2017 at 18:7 Comment(2)
SECRET_KEY_BASE is just a random string, and perl is more than capable of generating random strings. Read up on how to do that with perl. Maybe you can even skip perl and use /dev/random.Harriot
Note, some "with Ruby" ways can be found at #32235120Incentive
T
33

OK, I found out - using OpenSSL:

openssl rand -hex 64

Telestich answered 30/5, 2017 at 21:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.