Bug 2940 - Installing in $HOME should not require root privileges
Summary: Installing in $HOME should not require root privileges
Status: CLOSED WORKSFORME
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Build system (show other bugs)
Version: 7.9p1
Hardware: Other Linux
: P5 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-07 15:13 AEDT by Dan
Modified: 2019-10-09 15:11 AEDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan 2018-12-07 15:13:06 AEDT
I tried installing OpenSSH 7.9p1 in my home directory, which be possible without root privileges. "make install" failed with a permissions error. This is on Ubuntu 16.04.5 LTS:

$ ./configure --prefix=$HOME/tmp/openssh
$ make
$ make install
...
/bin/mkdir -p /home/smith/tmp/openssh/bin
/bin/mkdir -p /home/smith/tmp/openssh/sbin
/bin/mkdir -p /home/smith/tmp/openssh/share/man/man1
/bin/mkdir -p /home/smith/tmp/openssh/share/man/man5
/bin/mkdir -p /home/smith/tmp/openssh/share/man/man8
/bin/mkdir -p /home/smith/tmp/openssh/libexec
/bin/mkdir -p -m 0755 /var/empty
/bin/mkdir: cannot create directory ‘/var/empty’: Permission denied
Makefile:330: recipe for target 'install-files' failed
make: *** [install-files] Error 1
Comment 1 Darren Tucker 2018-12-07 17:38:29 AEDT
sshd requires a directory to chroot to  which by default is "/var/empty".   If your system has one and uses a different path you can tell configure to use -with-privsep-path=/somewhere else.
Comment 2 Ryan Williams 2019-07-25 19:23:03 AEST
Minor note: the flag is "--with-privsep-path" (two leading dashes)

It seems like "--prefix" should also be prepended to this "/var/empty" path, by default.
Comment 3 Darren Tucker 2019-07-25 21:02:23 AEST
(In reply to Ryan Williams from comment #2)
> It seems like "--prefix" should also be prepended to this
> "/var/empty" path, by default.

No, the usual path for that (/var/empty) is outside the usual prefix (/usr or /usr/local).  "make install" does already prepend DESTDIR (which defaults to an empty string) to all install paths including that one:

$(MKDIR_P) -m 0755 $(DESTDIR)$(PRIVSEP_PATH)

Assuming you don't want to run an unprivileged sshd you can do what you want with

$ ./configure --prefix=/ && make install-nokeys DESTDIR=/home/smith/tmp/openssh

If you want the host keys you would probably need to set them up by hand or fiddle with --sysconfdir.
Comment 4 Damien Miller 2019-10-09 15:11:41 AEDT
Close bugs fixed in openssh-8.1 release cycle