Can't connect the custom repository via SSH

alphachi

Member

Reaction score: 12
Messages: 63

I want to provide a custom repository via SSH, because this needn't install any package like apache or nginx, even pkg itself.

The server IP is 10.0.0.1/24:
Code:
root@Server:~ # cat /usr/local/etc/pkg/repos/FreeBSD.conf /usr/local/etc/pkg/repos/Local.conf
FreeBSD: {
  enabled: no
}
Local: {
  url: "file:///var/pkg"
}
root@Server:~ # pkg info
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from file:///var/pkg, please wait...
[Server] Installing pkg-1.17.2...
[Server] Extracting pkg-1.17.2: 100%
pkg-1.17.2                     Package manager

The client IP is 10.0.0.2/24:
Code:
root@Client:~ # cat /usr/local/etc/pkg/repos/FreeBSD.conf /usr/local/etc/pkg/repos/Local.conf
FreeBSD: {
  enabled: no
}
Local: {
  url: "ssh://10.0.0.1/var/pkg"
}
root@Client:~ # scp 10.0.0.1:/var/pkg/Latest/pkg.txz .
pkg.txz                                                        100% 7472KB  56.2MB/s   00:00
root@Client:~ # pkg info
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from ssh://10.0.0.1/var/pkg, please wait...
pkg: Error fetching ssh://10.0.0.1/var/pkg/Latest/pkg.txz: Invalid URL scheme
A pre-built version of pkg could not be found for your system.
Consider changing PACKAGESITE or installing it from ports: 'ports-mgmt/pkg'.

I think the ssh-repo format is wrong, but I can't find any example for this.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,325
Messages: 38,841

pkg(8) uses fetch(3) and that only supports FTP, HTTP(S) and the file scheme. If you want to do this with only the base system tools then ftpd(8) or NFS are an option. But really the simplest solution is to use www/nginx or www/lighttpd, basically any webserver that can serve a directory of files will do.
 
OP
A

alphachi

Member

Reaction score: 12
Messages: 63

pkg-ssh(8):
Code:
...
     pkg ssh provides a minimal package server.  It is most commonly used with
     the SSH transport protocol.

     This command is not meant to be used by the user.  pkg(8) will start the
     server automatically through ssh(1) when the ssh:// scheme is specified
     in the repository configuration.
...

pkg.conf(5):
Code:
...
     For a MIRROR_TYPE of NONE, any of the URL schemes supported by
     libfetch(3) can be used, including: http://, https://, ftp://, or
     file://.  In addition a ssh:// URL scheme is also supported.  Where
     MIRROR_TYPE is SRV, you should use a pkg+http:// or pkg+https:// (etc.)
     URL scheme.  Using an http:// URL implies that the hostname part is a
     simple hostname according to RFC 2616, and is no longer accepted.
...

In addtion, some options like PKG_SSH_ARGS and SSH_RESTRICT_DIR exist in pkg.conf(5).
I feel puzzled...
 

VladiBG

Daemon

Reaction score: 554
Messages: 1,201

It's not included in pkg-static you need to install pkg first from FreeBSD repo via http(s) pkg bootstrap
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,325
Messages: 38,841

Looks like it's a relatively new addition to pkg(8). But the problem is that pkg(7) doesn't support it. So you'll need to find another way to bootstrap it first.
 
OP
A

alphachi

Member

Reaction score: 12
Messages: 63

Yes, pkg(7) doesn't support SSH and pkg(8) supports it:
Code:
root@Server:~ # pkg info
pkg-1.17.2                     Package manager
root@Server:~ # pkg which `man -aw pkg-ssh pkg.conf`
/usr/local/man/man8/pkg-ssh.8.gz was installed by package pkg-1.17.2
/usr/local/man/man5/pkg.conf.5.gz was installed by package pkg-1.17.2

But bootstrap is easy:
Code:
root@Client:~ # scp 10.0.0.1:/var/pkg/Latest/pkg.txz .
pkg.txz                                                        100% 7472KB  55.8MB/s   00:00
root@Client:~ # pkg add pkg.txz && rm pkg.txz
[Client] Installing pkg-1.17.2...
[Client] Extracting pkg-1.17.2: 100%
root@Client:~ # pkg info
pkg-1.17.2                     Package manager
 
Top