When a pattern such as abc* is used unquoted in the shell, the shell will try to match it against the available filenames (this is called "filename generation" but is often referred to as "globbing"). If it fails to match any filename, most sh-like shells will leave the pattern unexpanded and pass it to the utility as is.
$ touch xyz
$ touch abc*
It is not possible during the PAM authentication -- the pam does not have any information about commands passed to the ssh. Only the ssh server can distinguish these types. But note that not passing the command argument to ssh means it internally executes the user shell (usually bash).
You can achieve what you describe by using the following in your ...
If you've got screen installed on the remote servers, try this, which will run the fstrim command inside a detached screen session. As far as ssh is concerned this will appear to exit immediately.
ssh firstname.lastname@example.org.X.X screen -S fstrim -md fstrim /data
You can reattach to the session with
ssh -tt email@example.com.X.X. screen -r fstrim
and disconnect again ...
nbtstat is a windows command.
nmblookup may be an alternative to nbtstat, it can be installed through:
sudo apt install samba-common-bin
manpages ( man nmblookup):
nmblookup - NetBIOS over TCP/IP client used to lookup NetBIOS names
Is atd running on the appliance? If so, you can schedule an immediate at job:
ssh firstname.lastname@example.org.X.X "echo 'fstrim /data' | at now"
Your remote session will terminate immediately, because all it's doing is scheduling the job. The atd daemon takes care of actually executing it.
"...under path /home"
Does it really say so? That would explain all this misunderstanding. "Under path $HOME" would make more sense...
/home/$USER could be another notation for "your" home directory. Normally it should just ask you to "create a etc.txt in your home directory"
For a "detailed content" use also -l option:
ls -alR /etc >~/etc.txt
I'm assuming you want to write this to your home directory rather than /home. You home directory will normally be /home/username, or you can use ~ which represents your home directory.
You should you find rather than ls to find all files under /etc.
find /etc -type f > ~/etc.txt
Using find like this could also be error prone though, if files have a ...
Specifically addressing the question of why your sed syntax doesn't work, process substitution will not occur inside single quotes.
This syntax works for me:
sed -i.old "1s;^;$(cat random)\\
If you're using GNU sed, this will work also:
sed -i.old "1s;^;$(cat random)\n;" filename
Addressing your edit, and focusing on GNU sed, two solutions ...
The exit executed by the remote shell would terminate that shell. In the case when true is executed, the remote shell would terminate due to not having any further commands to execute, but exit would terminate it even if there were further commands afterwards (as in any script).
In the simple case where the SSH session is only for executing a set of ...
The ipset has a reference counter built-in. So whenever it's referenced by iptables, its references counter gets increased. As far as I know, only ipset's meta set list:set and iptables reference an ipset. If you're not using list:set or not altering it, you can query directly ipset (with ipset list) to know if it was referenced by iptables.