# How to copy credentials in node-red flow?

**URL:** <https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315>\
**Category:** General\
**Created:** [19 March 2020 12:15 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315 "2020-03-19T12:15:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![hsn548](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hsn548/32/17530_2.png) [@hsn548](https://discourse.nodered.org/u/hsn548)\
**Post date:** [19 March 2020 12:15 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315/1 "2020-03-19T12:15:17Z")

</div>

I have a mqtt node and in the mqtt node, I have all the credentials e.g. password, username etc and I am taking the password and username from the environment variables like this $(Password).

Now when i export the flow and paste it to another node-red, my username and password field is always empty hence flow doesnt contain the credentials.  
So my question is,how can i also copy the credentials with the flow?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [19 March 2020 12:29 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315/2 "2020-03-19T12:29:03Z")

</div>

The credentials are stored in a separate file eg. `flows_cred.json`  
As a security measure you won't be copying/pasting credentials and this makes them more easily exportable without running the risk of exposing credentials.

So to answer your question, you cannot export the flow _with_ credentials.

---

<div class="post-metadata">

**Author:** ![hsn548](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hsn548/32/17530_2.png) [@hsn548](https://discourse.nodered.org/u/hsn548)\
**Post date:** [19 March 2020 12:38 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315/3 "2020-03-19T12:38:02Z")

</div>

Thanks @bakman2, is there any work around for that? as i am getting my username and password from the environment variables and its not actually text fields

---

<div class="post-metadata">

**Author:** ![hsn548](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hsn548/32/17530_2.png) [@hsn548](https://discourse.nodered.org/u/hsn548)\
**Post date:** [19 March 2020 12:43 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315/4 "2020-03-19T12:43:13Z")

</div>

is there any way to copy the credentials in the flow before running the node-red? or during the node-red ?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [19 March 2020 12:58 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315/5 "2020-03-19T12:58:49Z")

</div>

As @bakman2 almost said... as the credentials are in a separate file - you will need to copy that over manually to the new system. maybe scp if you are using linux/mac. usb stick, etc...

---

<div class="post-metadata">

**Author:** ![hsn548](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hsn548/32/17530_2.png) [@hsn548](https://discourse.nodered.org/u/hsn548)\
**Post date:** [19 March 2020 13:03 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315/6 "2020-03-19T13:03:05Z")

</div>

That means with the flow i should also copy flow\_cred.json file? i tried that but it doesnt work.. maybe some other problem.. i will take a look at it.. thanks

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 March 2020 13:36 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315/7 "2020-03-19T13:36:53Z")

</div>

I think (though not certain) that you also you must use a credentials secret in settings.js as this is used to decrypt the credentials and copy that across too.

---

<div class="post-metadata">

**Author:** ![hsn548](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hsn548/32/17530_2.png) [@hsn548](https://discourse.nodered.org/u/hsn548)\
**Post date:** [19 March 2020 13:47 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315/8 "2020-03-19T13:47:21Z")

</div>

my credentialSecret is commented.. is there any default secret too?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [19 March 2020 13:54 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315/9 "2020-03-19T13:54:31Z")

</div>

Look in `~/.node-red/.config.json` for the `_credentialSecret` value. That is the auto-generated value that is used if you don't provide your own in your settings file. Copy its value over to your settings file under `credentialSecrets` key.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 April 2020 13:54 UTC](https://discourse.nodered.org/t/how-to-copy-credentials-in-node-red-flow/23315/10 "2020-04-02T13:54:42Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
