# Trying to use openssl passwd with exec node

**URL:** <https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071>\
**Category:** General\
**Created:** [27 December 2023 21:31 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071 "2023-12-27T21:31:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [27 December 2023 21:31 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/1 "2023-12-27T21:31:37Z")

</div>

Hello

I am trying to encrypt a password using openssl passwd and an exec node. Flow looks like this:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/20ef52f61a586a77a356db54f8b321f297f6dc49.png)

The code in the encrypt pin function is this:

msg.payload = "-salt abcdef" + global.get("pincode");  
return msg;

pincode is a string.

The exec node has the following: openssl passwd

When I execute the function, a PID # appears under the exec node, so I know it has ran.

However I get nothing out of the exec node, it should be returning the encrypted version of the "pincode" variable.

Any ideas on what I am doing wrong?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 December 2023 00:05 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/2 "2023-12-28T00:05:12Z")

</div>

Try using the other 2 outputs and sending them to debug to see what error is being produced. I suspect that openssl requires `sudo` but I'm not sure.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [28 December 2023 20:37 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/3 "2023-12-28T20:37:57Z")

</div>

Thanks for the reply. I have 3 debug nodes connected to the 3 outputs set to display the complete msg object and I am seeing nothing in the debug window.

I don't think you need to be sudo, I can run that command in the terminal without beings sudo.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 December 2023 20:46 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/4 "2023-12-28T20:46:22Z")

</div>

> [@Sirhc](#):
>
> I can run that command in the terminal without beings sudo

When you run in the terminal, you typically get an entirely different configuration - see what env variables you get in the terminal or assumptions by openssh as to the location of configuration files. These will all be different when run from within Node-RED.

I don't remember the config for openssh off the top of my head so I can't help directly, you will need to do some reading about it.

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [28 December 2023 21:01 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/5 "2023-12-28T21:01:16Z")

</div>

that's ok, I figured it out, you need -noverify in the exec node otherwise openssl passwd sits there waiting for confirmation of the password

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [28 December 2023 21:22 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/6 "2023-12-28T21:22:31Z")

</div>

One other issue I am having.. The exec node returns this payload:

abvc

I then have this function node to compare the result:

> var alarm\_function\_tmp = msg.payload;
> 
> if (alarm\_function\_tmp === "abvc") {
> 
> var alarm\_pass\_fail\_tmp = "ENTER PINCODE";
> 
> msg.pass=alarm\_pass\_fail\_tmp;
> 
> msg.success = 1;
> 
> msg.passthru = alarm\_function\_tmp;
> 
> return msg;
> 
> } else if (alarm\_function\_tmp != "abvc") {
> 
> var alarm\_pass\_fail\_tmp = "INCORRECT PIN";
> 
> msg.pass=alarm\_pass\_fail\_tmp;
> 
> msg.passthru = alarm\_function\_tmp;
> 
> return msg;
> 
> }

However I cannot get the === statement to equate true.

The strings are the same? I'm not sure what I am missing

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [28 December 2023 21:27 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/7 "2023-12-28T21:27:30Z")

</div>

Not sure

```js
var alarm_function_tmp = msg.payload.join("");

```

Can be simplified to

```diff
- } else if (alarm_function_tmp != "$1$4312$l7ibmh5zfQTHChznRX5i7.") {
+ else {

```

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [28 December 2023 21:35 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/8 "2023-12-28T21:35:50Z")

</div>

Thanks for the reply but that didn't work either ☹

---

<div class="post-metadata">

**Author:** ![Sirhc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sirhc](https://discourse.nodered.org/u/Sirhc)\
**Post date:** [28 December 2023 21:43 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/9 "2023-12-28T21:43:47Z")

</div>

I got it to work, used msg.slice to clean up the exec nod

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 December 2023 21:57 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/10 "2023-12-28T21:57:31Z")

</div>

just do `msg.payload.trim()` since the command line output includes a newline.

---

<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:** [26 February 2024 21:57 UTC](https://discourse.nodered.org/t/trying-to-use-openssl-passwd-with-exec-node/84071/11 "2024-02-26T21:57:33Z")

</div>

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