You are not logged in.

#1 2014-09-19 16:31:44

badhat
Member
Registered: 2011-01-30
Posts: 112

chroot ssh user -- permission denied

I'd like to figure out the best way to let some friends remote forward an ssh connection to my server for the sole purpose supporting them without explaining how to setup of port forwarding on a route every time.

myserver% grep prison /etc/passwd
prisoner:x:1001:1001:Jailed chroot user for support:/home/prisoner:/bin/bash

myserver% ll /var/chroot
total 164
drwxr-xr-x 1 root     root          8 Sep 19 11:38 bin
drwxr-xr-x 1 root     root          8 Sep 19 11:11 dev
drwxr-xr-x 1 root     root          0 Sep 19 11:10 etc
drwxr-xr-x 1 root     root          0 Sep 19 11:10 lib
-rwxr-xr-x 1 root     root     164148 Sep 19 11:14 lib64
drwx------ 1 prisoner prisoner     98 Sep 19 11:43 prisoner
drwxr-xr-x 1 root     root         12 Sep 19 11:14 usr

myserver% cat /etc/ssh/sshd_config
Match user prisoner
    ChrootDirectory /var/chroot
    X11Forwarding no
    AllowTCPForwarding yes

When I try to login as prisoner I get an error. Any tips?

prisoner@127.0.0.1's password:
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.

Offline

#2 2014-09-19 17:15:23

branch
Member
Registered: 2014-03-16
Posts: 209

Re: chroot ssh user -- permission denied

Two probems is see:
1) /var/chroot/prisoner should be /var/chroot/home/prisoner
2) /var/chroot/lib64 is a file not a directory (or link to a directory)

But there could of course be other issues depending on the contents of your fake root tree and sshd_config.

Offline

#3 2014-09-19 17:55:57

badhat
Member
Registered: 2011-01-30
Posts: 112

Re: chroot ssh user -- permission denied

I'm not getting much help as far as which file's permissions are incorrect. I made the changes you noted in 1 and 2:

myserver% grep prison /etc/passwd
prisoner:x:1001:1001:Jailed chroot user for support:/home/prisoner:/usr/bin/bash

myserver% ll /var/chroot
total 0
drwxr-xr-x 1 root root  0 Sep 19 13:37 bin
drwxr-xr-x 1 root root  8 Sep 19 11:11 dev
drwxr-xr-x 1 root root  0 Sep 19 11:10 etc
drwxr-xr-x 1 root root 16 Sep 19 13:43 home
drwxr-xr-x 1 root root  0 Sep 19 11:10 lib
drwxr-xr-x 1 root root 40 Sep 19 13:40 lib64
drwxr-xr-x 1 root root 12 Sep 19 11:14 usr


myserver% ll /var/chroot/home
total 0
drwx------ 1 prisoner prisoner 98 Sep 19 11:43 prisoner

prisoner@127.0.0.1's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.

You wanted to see the structure?

myserver% tree /var/chroot
/var/chroot
├── bin
├── dev
│   └── null
├── etc
│   ├── group
│   ├── hosts
│   ├── ld.so.cache
│   ├── ld.so.conf
│   ├── nsswitch.conf
│   ├── passwd
│   └── shadow
├── home
│   └── prisoner [error opening dir]
├── lib
├── lib64
│   └── ld-linux-x86-64.so.2
└── usr
    ├── bin
    │   └── bash
    └── lib
        ├── libc.so.6
        ├── libdl.so.2
        ├── libncursesw.so.5
        └── libreadline.so.6

10 directories, 14 files

*EDIT
At least the chroot work, but perhaps there is something with PAM that is preventing me from logging in with ssh.

myserver% sudo chroot /var/chroot /usr/bin/bash
bash-4.3#

Last edited by badhat (2014-09-19 19:09:44)

Offline

#4 2014-09-19 19:36:58

branch
Member
Registered: 2014-03-16
Posts: 209

Re: chroot ssh user -- permission denied

Can you ssh as prisoner without the "ChrootDirectory /var/chroot" line in sshd_config?

If so then it is likely a problem with the chroot tree. I would try recreating it as follows (requires the arch-install-scripts package):

sudo mv /var/chroot /var/chroot-orig
sudo mkdir /var/chroot
sudo pacstrap -c -d /var/chroot base

Offline

#5 2014-09-19 20:16:43

badhat
Member
Registered: 2011-01-30
Posts: 112

Re: chroot ssh user -- permission denied

Without the ChrootDirectory line I don't think it will work because the home directory set for prisoner is relative to the change root, true?
I don't want to install all of base, just bash., so the option of setting up a new tree with bash is way overkill and not in line with my goal.

Offline

#6 2014-09-19 20:38:59

branch
Member
Registered: 2014-03-16
Posts: 209

Re: chroot ssh user -- permission denied

1) It should work but with a warning that it could not find the home directory. Just try it.

2) Sure it's overkill, but it's a place to start. See if it works. If it still does not work, the problem is somewhere else. If it works then remove stuff you don't need and see if it still works.

Offline

Board footer

Powered by FluxBB