Can't SSH into Pi-Hole (LXC Container)

The issue I am facing:
Pi-Hole is up and running fine and I can login to the web interface. Today was the first time I wanted to update, but I couldn't remember if or how I ever accessed Pi-Hole through SSH.

Note: Both the LXC container and the user in that container actually running Pi-Hole are named pihole. Sorry if this makes it confusing..

First thing I tried was SSHing into the host machine that is running the LXC container with Pi-Hole:

  1. SSHed into the host machine
  2. I am now root@host (i.e. I'm root of the system that's running the container)
  3. Run lxc-attach -n pihole
  4. I am now root@pihole (i.e. I'm root of the container with Pi-Hole on it)
  5. pihole is not a recognized command

So, as root@pihole, I try switching to the user running Pi-hole (imaginatively named pihole):

  1. su pihole
  2. "This account is currently not available."

Odd. At this point I want to SSH into Pi-Hole without first going through the host of the container. I should be able to do this since the LXC container has a IP I know, but I don't have the password handy. So I change it while being root@pihole (passwd pihole).

Now that I know the password, I try to SSH into pihole@[IPofLXC]

Could not chdir to home directory /home/pihole: No such file or directory
This account is currently not available.
Connection to [IPofLXC] closed.

Appreciate any help! Otherwise my unupdatable system will slowly rot away... :melting_face:

Details about my system:
Turris Omnia with a LXC Container (Debian Bookworm)

What I have changed since installing Pi-hole:
Don't think anything of significance changed

Thats an OS thing and not a Pi-hole issue.

That real pihole user only exists for running the pihole-FTL daemon (EDIT: not for ssh access):

$ ps -o uid,user,gid,group,pid,cmd -C pihole-FTL
  UID USER       GID GROUP      PID CMD
  999 pihole     995 pihole   31873 /usr/bin/pihole-FTL -f

It doesnt need a password to be set for that.
Besides this user not having a home folder, you would not be able to login with it bc the shell for that user is set to /usr/sbin/nologin:

$ grep pihole /etc/passwd
pihole:x:999:995::/home/pihole:/usr/sbin/nologin
$ stat /home/pihole
stat: cannot statx '/home/pihole': No such file or directory
1 Like

Wow, that was fast! Thanks, that makes sense.. I didn't see the user/group shown in Settings -> System is under the header FTL Information, oops.

So now I know that this is definitely not an issue with Pi-Hole itself, but I'd be grateful if someone could help me SSH into the Pi-Hole. I can't find any info about this problem online.

I thought maybe I just... forgot about the user that's running it, but none of the users that cat /etc/passwd returns seem appropriate :face_with_diagonal_mouth:

output of cat /etc/passwd

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
_apt:x:42:65534::/nonexistent:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
messagebus:x:100:101::/nonexistent:/usr/sbin/nologin
systemd-network:x:998:998:systemd Network Management:/:/usr/sbin/nologin
systemd-resolve:x:997:997:systemd Resolver:/:/usr/sbin/nologin
pihole:x:996:1000::/home/pihole:/usr/sbin/nologin
sshd:x:101:65534::/run/sshd:/usr/sbin/nologin

Is the following scenario likely? When I installed Pi-Hole, I 1) created a user named pihole and 2) ran the Pi-Hole installer script under that user which overwrote that user somehow? Is that even technically possible?

I have another Pi-Hole installation running on a Raspberry Pi 0, where I simply used Raspberry Pi OS and the default pi user, so I'm not a complete beginner and shouldn't have messed up the installation itself.

1 Like

It does not seem that you have a normal user listed on the system ( a normal user would have a UID of >1000 and a GUID of >1000 ie pi:x:1000:1000...

As you can login in via root then consider creating a user via:

sudo adduser

and then give it sudo access using :

sudo usermod -aG sudo <user>
2 Likes

They all have no shell except the root user.
But that one isnt allowed to SSH in on most distros OOTB:

$ man sshd_config
[..]
     PermitRootLogin
             Specifies whether root can log in using ssh(1).  The
             argument must be yes, prohibit-password,
             forced-commands-only, or no.  The default is
             prohibit-password.

             If this option is set to prohibit-password (or its dep‐
             recated alias, without-password), password and key‐
             board-interactive authentication are disabled for root.

             If this option is set to forced-commands-only, root lo‐
             gin with public key authentication will be allowed, but
             only if the command option has been specified (which
             may be useful for taking remote backups even if root
             login is normally not allowed).  All other authentica‐
             tion methods are disabled for root.

             If this option is set to no, root is not allowed to log
             in.

I have no experience with LXC containers but if the adduser command is available when you attach as the root user, you could try create a new user name thats able to login via SSH with below:

adduser <NEW_USERNAME>

Yes it could I think :wink:

EDIT: Does below folder exist?

That might indicate the user already existed before you installed Pi-hole.

1 Like

I just added the user "pi" and it works! There is apparently no /home/pihole, which makes it seem like I installed Pi-Hole without ever using the terminal somehow :person_shrugging:

I'm always amazed by how supportive FOSS communities are. You guys rock for taking a few minutes out of your day to help total strangers!

2 Likes

Didnt you just attach as the root user to run the install?
If you login/attach as root, you could check:

history

Or grep for it:

$ grep install.pi-hole.net ~/.bash_history
curl -sSL https://install.pi-hole.net | bash

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.