I have an application that I need to constrain the user to operate a serial console.
This works perfectly fine:
myuser:x:1005:1005:Someone,,,:/home/myuser:/usr/bin/minicom
However, I realize that I also need to capture the serial console, so I actually need to call minicom with
minicom -C somefile
And neither of these work:
myuser:x:1005:1005:Someone,,,:/home/myuser:/usr/bin/minicom -C somefile
myuser:x:1005:1005:Someone,,,:/home/myuser:"/usr/bin/minicom -C somefile"
myuser:x:1005:1005:Someone,,,:/home/myuser:'/usr/bin/minicom -C somefile'
I get an Failed password for invalid user myuser from XXXXXX error message.
I've also tried to leave /bin/bash as the shell in /etc/passwd and add /usr/bin/minicom -C somefile to myuser's .bashrc file, but the user can exit minicom and drop to an interactive shell, which I do not want.
I also tried to create a bash script
myuser:x:1005:1005:Someone,,,:/home/myuser:/home/myuser/runthis.sh
runthis.sh:
#/bin/bash
/usr/bin/minicom -C capture.log
But I get an exec format error when trying to log in.
Is there a way to call minicom from /etc/passwd with an argument?
Much thanks!
!in your script's "shebang"? it should be#!/bin/bash– steeldriver Feb 27 '21 at 22:09