I am trying to find a way to determine the user name of the current shell user from within a shell / terminal on an Android device.
The Android environment that I have in /system/bin
and /system/xbin
does not have the unix user
command. Overall, it appears that the concept doesn't quite exist on Android, but at least, on my rooted device, there is a user root
and also there are groups such as shell
and everybody
, based on the permissions of files on the system.
The background is the following:
I want to run an ssh
command (I installed a version of OpenSSH also) on the Android that uses a local private key
. The key has file permissions and those are required to be restrictive by OpenSSH for good reason (the UNIX group of the file should not have permissions to access the key, only the owner).
Since I know only the user root
, I can set the owner of the key to root
and run ssh
as root. However, I don't really want to run ssh
as root.
I am issuing the shell command from within Automate
which has that option. Apparently, it's possible to execute the command without root permissions. However, if I add the key file to the ssh
command, it can't get access to the file that is accessible only by root
. Thus I would like to set the owner in the UNIX file permissions of the key to the shell user used by Automate
, but I do not know how to find out who that is.
EDIT:
~# grep automate /data/system/packages.list
com.llamalab.automate 10106 0 /data/user/0/com.llamalab.automate default:targetSdkVersion=24 3002,3003,3001
I assume 10106
is the UID, but is that a static value? If yes, could I add a line to /etc/passwd
by using adduser
command from busybox or Termux?