Closed jroovy closed 3 weeks ago
You likely need to run chown -R root:root "$PREFIX/etc/ssh"
if running sshd
as root. This obviously will have the implication that you will need to wipe $PREFIX
manually with root if ever needed (like termux-reset
), as termux app/user owned processes will not be able to do it, and possibly openssh
package updates will fail as well and ownership will need to be restored first.
I see....I'll make a bash script that does this for me
Might wanna test it first ;)
Running ssh
as root at least requires ~/.ssh
to be owned by root user.
Might wanna test it first ;)
Running
ssh
as root at least requires~/.ssh
to be owned by root user.
Does it? I was able to run ssh as root without changing ownership of ~/.ssh
Here's my script for running ssh as root:
#!/data/data/com.termux/files/usr/bin/sh
user=$(whoami)
if [ $user = root ]; then
printf '%s\n' 'This script <should not> be run as root.'
exit
fi
sudo chown -R root:root "$PREFIX/etc/ssh"
sudo ssh "$@"
sudo chown -R $user:$user "$PREFIX/etc/ssh"
I'll have to edit the script further for sshfs
EDIT: maybe not, since sshfs runs in the background and the permissions get reverted after sshfs has been executed
EDIT 2: replace sudo ssh "$@"
with sudo sshfs "$@"
and it should also work for sshfs
Does it? I was able to run ssh as root without changing ownership of ~/.ssh
It's the ownership of ~/.ssh/config
that matters, you have likely not created it.
if [ $user = root ]; then exit
If you exit if root, then how do you expect to change ownership with chown to root, which itself also doesn't make sense in that case.
If you exit if root, then how do you expect to change ownership with chown to root, which itself also doesn't make sense in that case.
with sudo
The user=$(whoami)
stores the uid of the non-root user. So if the script is run with root then $user
will not have the uid of the non-root user.
It's the ownership of
~/.ssh/config
that matters, you have likely not created it.
I see. Yes, I don't have a config file in the ~/.ssh folder.
whoami
prints the current effective user id, which will be root
if running under sudo
and not some non-root user.
If you want to prevent nested running of script if already root, then use something like this.
#!/data/data/com.termux/files/usr/bin/bash
if [[ $EUID -ne 0 ]]; then
exec sudo bash "$0" "$@"
fi
ssh...
9.9p1-4
will ignore ownership of configuration files, so chown
won't be needed anymore.
However world-writeable permissions (e.g. default permissions with umask 0000
) still trigger the error. That should be expected.
whoami
prints the current effective user id, which will beroot
if running undersudo
and not some non-root user.If you want to prevent nested running of script if already root, then use something like this.
#!/data/data/com.termux/files/usr/bin/bash if [[ $EUID -ne 0 ]]; then exec sudo bash "$0" "$@" fi ssh...
I think you meant the $USER variable. $user (lowercase) is a completely different variable.
~ $ user=$(whoami)
~ $ echo $user
u0_a491
~ $ sudo echo $user
u0_a491
EDIT: sorry, I misunderstood your comment
9.9p1-4 will ignore ownership of configuration files, so chown won't be needed anymore.
I can confirm its fixed :+1:
Problem description
Trying to ssh into a system as a root user will spawn this error:
Bad owner or permissions on /data/data/com.termux/files/usr/etc/ssh/ssh_config.d/custom.conf
This is especially a problem when trying to mount a remote sshfs, which requires root permissionsWhat steps will reproduce the bug?
tsu
Bad owner or permissions on /data/data/com.termux/files/usr/etc/ssh/ssh_config.d/custom.conf
What is the expected behavior?
Should be able to login to remote system without any issues.
System information