# How to pass a password in the exec node

**URL:** https://discourse.nodered.org/t/how-to-pass-a-password-in-the-exec-node/10814
**Category:** General
**Created:** [4 May 2019 16:38 UTC](https://discourse.nodered.org/t/how-to-pass-a-password-in-the-exec-node/10814 "2019-05-04T16:38:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mike67](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@mike67](https://discourse.nodered.org/u/mike67)
#### Post date: [4 May 2019 16:38 UTC](https://discourse.nodered.org/t/how-to-pass-a-password-in-the-exec-node/10814/1 "2019-05-04T16:38:40Z")

</div>

Hello  
I need to send a command like  
`sudo openport 1234` with a exec node  
When I run this command in the terminal, I'm asked for the user password.

How can i pass this password in the exec node?  
Thanks

---

<div class="post-metadata">

### Author: ![nlecaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nlecaude/32/25_2.png) [@nlecaude](https://discourse.nodered.org/u/nlecaude)
#### Post date: [4 May 2019 17:26 UTC](https://discourse.nodered.org/t/how-to-pass-a-password-in-the-exec-node/10814/2 "2019-05-04T17:26:39Z")

</div>

You'll have to tell your os not to use a password for that specific command, here are some hints:

> <https://askubuntu.com/questions/159007/how-do-i-run-specific-sudo-commands-without-a-password>

---

<div class="post-metadata">

### Author: ![mike67](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@mike67](https://discourse.nodered.org/u/mike67)
#### Post date: [4 May 2019 19:55 UTC](https://discourse.nodered.org/t/how-to-pass-a-password-in-the-exec-node/10814/3 "2019-05-04T19:55:04Z")

</div>

Hello.  
Thanks for this hint, but I would prefer not to chnage anything in the config files.  
Is there any other way to add a password to a sudo command with the exec node (or with an other node)?

---

<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: [4 May 2019 20:08 UTC](https://discourse.nodered.org/t/how-to-pass-a-password-in-the-exec-node/10814/4 "2019-05-04T20:08:52Z")

</div>

I do not believe that is possible. The only way is to tell the OS that the node red user does not need to enter a password for the command you require to run.

---

<div class="post-metadata">

### Author: ![nlecaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nlecaude/32/25_2.png) [@nlecaude](https://discourse.nodered.org/u/nlecaude)
#### Post date: [4 May 2019 20:29 UTC](https://discourse.nodered.org/t/how-to-pass-a-password-in-the-exec-node/10814/5 "2019-05-04T20:29:52Z")

</div>

This page seems to have some tips:

> <https://superuser.com/questions/67765/sudo-with-password-in-one-command-line>

  
Security wise this is very bad though...

---

<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: [4 May 2019 20:40 UTC](https://discourse.nodered.org/t/how-to-pass-a-password-in-the-exec-node/10814/6 "2019-05-04T20:40:36Z")

</div>

I never knew you could do that, so yes  
`sudo 'thepassword' | sudo -kS command`  
does appear to work. However your system password will exist as plain text in a file, which is a very bad idea. Much better to tell the system that you don't need a password just for the commands you require, so at least you are limiting the damage that can be done.
