Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    though the solution is simply (set up key-based authentication in your SSH), this really is not something you want to run in your .bashrc. Also, your local sudo is completely superfluous. Commented Sep 22, 2023 at 16:11
  • So, taking a step back: you just want to have a program that when you log in automatically shows you a live packet dump from a different computer. Why not simply write that as a script? Commented Sep 22, 2023 at 16:12
  • @terdon Executing a function via sudo? No. Note that the user is single-quoting the $2 and that there is no indication what the difference between "running this on a Linux machine" and "running this in the terminal" is (or even what "this" is). The sudo is a red herring and we don't know what the actual issue is. Commented Sep 23, 2023 at 12:29
  • Oh man. Sorry about that, of course @Kusalananda is absolutely right and you cannot run user-defined functions via sudo (not without jumping through several hoops and opening yourself to security issues). I was thinking there may have been an issue with ssh consuming stdin which is why the password prompt wasn't appearing, but I think I was just completely wrong. I read the question as the command working when executed directly but failing when used as a function. Commented Sep 23, 2023 at 14:04