How do I set up env variables in linode for a third party api key?

I have set up my Linode with a node.js express app. I am using a third party mail server Send Grid to send emails. How do I set up environment variables such as Api key in my linode.
For example in Heroku I would just input these in their GUI somewhere and I can access it through the app/script.

I would appreciate if you have a solution.
Thanks in advance.

1 Reply

Hi there,

While researching SendGrid I came across this nifty section in their documentation that includes an interactive/editable example for how you can configure these environment variables. You can find this below:

Essentially, you want to set the environment variable from within the Linode itself. You can do this by using SSH or Lish to access the Linode. You could then either assign an environment variable or create a configuration file. For what it's worth, SendGrid recommends that if you choose to use a config file that you should make sure that it is not stored in version control.

Here's an example from the SendGrid documentation that shows how to store your key in a variable named SENDGRID_API_KEY:

From your Linode's command line you could use the following commands:

export SENDGRID_API_KEY=the_key_you_copied_from_SendGrid

To then access the variable, you can use the convention provided by your coding language.

const apiKey = process.env.SENDGRID_API_KEY;

I hope this helps!


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct