Skip to contentSkip to conversation

package/openssh: allow separate selection of client, server, keyutils

PATCH New Thomas De Schampheleire 1 participant 3 messages Apr 6, 2020 – Apr 28, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/openssh: allow separate selection of client, server, keyutils

From: Thomas De Schampheleire <[email protected]>

The openssh package comprises three separate entities: the SSH client, SSH server, and some SSH key utilities. One may want the client but not the server, the server but not the client, or maybe only the key utilities.

Add separate options for each entity and update the files installed on target accordingly.

On an ARM Cortex-A53 configuration, size of stripped binaries are:

Client programs: 2213118 bytes (2161 KB)
usr/bin/ssh,657180
usr/bin/scp,99836
usr/bin/ssh-add,312800
usr/bin/ssh-agent,296428
usr/libexec/ssh-keysign,398908
usr/libexec/ssh-pkcs11-helper,292316
usr/bin/sftp,144992
usr/bin/ssh-copy-id,10658

Server programs: 806840 bytes (787 KB)
usr/libexec/sftp-server,112140
usr/sbin/sshd,694168
etc/init.d/S50sshd,532

Key utilities: 789648 bytes (771 KB)
usr/bin/ssh-keygen,398924
usr/bin/ssh-keyscan,390724

---
 package/openssh/Config.in  | 23 +++++++++++++++++++++++
 package/openssh/openssh.mk | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 1 deletion(-)
package/openssh/Config.in +23 -0
index 683a9c0e51..cc5998742e 100644
@@ -9,3 +9,26 @@ config BR2_PACKAGE_OPENSSH
 	  friends.
 
 	  http://www.openssh.com/
+
+if BR2_PACKAGE_OPENSSH
+
+config BR2_PACKAGE_OPENSSH_CLIENT
+	bool "client"
+	default y
+	help
+	  Client programs: ssh, scp, sftp, ssh-agent, ssh-add,
+	  ssh-copy-id.
+
+config BR2_PACKAGE_OPENSSH_SERVER
+	bool "server"
+	default y
+	help
+	  Server programs: sshd, sftp-server
+
+config BR2_PACKAGE_OPENSSH_KEY_UTILS
+	bool "key utilities"
+	default y
+	help
+	  Key utilities: ssh-keygen, ssh-keyscan.
+
+endif
package/openssh/openssh.mk +30 -1
index d50572128a..b0259de7dd 100644
@@ -82,10 +82,39 @@ define OPENSSH_INSTALL_INIT_SYSV
 		$(TARGET_DIR)/etc/init.d/S50sshd
 endef
 
+ifeq ($(BR2_PACKAGE_OPENSSH_CLIENT),y)
 define OPENSSH_INSTALL_SSH_COPY_ID
 	$(INSTALL) -D -m 755 $(@D)/contrib/ssh-copy-id $(TARGET_DIR)/usr/bin/ssh-copy-id
 endef
-
 OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_INSTALL_SSH_COPY_ID
+else
+define OPENSSH_REMOVE_CLIENT
+	for i in ssh scp sftp ssh-agent ssh-add ; do \
+		rm -f $(TARGET_DIR)/usr/bin/$$i ; \
+	done
+	for i in ssh-keysign ssh-pkcs11-helper ; do \
+		rm -f $(TARGET_DIR)/usr/libexec/$$i ; \
+	done
+endef
+OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_REMOVE_CLIENT
+endif
+
+ifneq ($(BR2_PACKAGE_OPENSSH_SERVER),y)
+define OPENSSH_REMOVE_SERVER
+	rm -f $(TARGET_DIR)/usr/sbin/sshd
+	rm -f $(TARGET_DIR)/usr/libexec/sftp-server
+	rm -f $(TARGET_DIR)/etc/init.d/S50sshd
+endef
+OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_REMOVE_SERVER
+endif
+
+ifneq ($(BR2_PACKAGE_OPENSSH_KEY_UTILS),y)
+define OPENSSH_REMOVE_KEY_UTILS
+	for i in ssh-keygen ssh-keyscan ; do \
+		rm -f $(TARGET_DIR)/usr/bin/$$i ; \
+	done
+endef
+OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_REMOVE_KEY_UTILS
+endif
 
 $(eval $(autotools-package))
Signature · 1 line
2.24.1
#1 lore raw

PATCH 1/1 package/openssh: allow separate selection of client, server, keyutils

Hi,

Quoted 104 lines · On Mon, Apr 6, 2020, 15:56 Thomas De Schampheleire <…

From: Thomas De Schampheleire <[email protected]>

The openssh package comprises three separate entities: the SSH client, SSH server, and some SSH key utilities. One may want the client but not the server, the server but not the client, or maybe only the key utilities.

Add separate options for each entity and update the files installed on target accordingly.

On an ARM Cortex-A53 configuration, size of stripped binaries are:

Client programs: 2213118 bytes (2161 KB)
usr/bin/ssh,657180
usr/bin/scp,99836
usr/bin/ssh-add,312800
usr/bin/ssh-agent,296428
usr/libexec/ssh-keysign,398908
usr/libexec/ssh-pkcs11-helper,292316
usr/bin/sftp,144992
usr/bin/ssh-copy-id,10658

Server programs: 806840 bytes (787 KB)
usr/libexec/sftp-server,112140
usr/sbin/sshd,694168
etc/init.d/S50sshd,532

Key utilities: 789648 bytes (771 KB)
usr/bin/ssh-keygen,398924
usr/bin/ssh-keyscan,390724

---
 package/openssh/Config.in  | 23 +++++++++++++++++++++++
 package/openssh/openssh.mk | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 1 deletion(-)
package/openssh/Config.in +23 -0
index 683a9c0e51..cc5998742e 100644
@@ -9,3 +9,26 @@ config BR2_PACKAGE_OPENSSH
          friends.
 
          http://www.openssh.com/
+
+if BR2_PACKAGE_OPENSSH
+
+config BR2_PACKAGE_OPENSSH_CLIENT
+       bool "client"
+       default y
+       help
+         Client programs: ssh, scp, sftp, ssh-agent, ssh-add,
+         ssh-copy-id.
+
+config BR2_PACKAGE_OPENSSH_SERVER
+       bool "server"
+       default y
+       help
+         Server programs: sshd, sftp-server
+
+config BR2_PACKAGE_OPENSSH_KEY_UTILS
+       bool "key utilities"
+       default y
+       help
+         Key utilities: ssh-keygen, ssh-keyscan.
+
+endif
package/openssh/openssh.mk +1 -0
index d50572128a..b0259de7dd 100644
@@ -82,10 +82,39 @@ define OPENSSH_INSTALL_INIT_SYSV
                $(TARGET_DIR)/etc/init.d/S50sshd
 endef
 
+ifeq ($(BR2_PACKAGE_OPENSSH_CLIENT),y)
 define OPENSSH_INSTALL_SSH_COPY_ID
        $(INSTALL) -D -m 755 $(@D)/contrib/ssh-copy-id

$(TARGET_DIR)/usr/bin/ssh-copy-id
endef

package/openssh/openssh.mk +21 -1
-
 OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_INSTALL_SSH_COPY_ID
+else
+define OPENSSH_REMOVE_CLIENT
+       for i in ssh scp sftp ssh-agent ssh-add ; do \
+               rm -f $(TARGET_DIR)/usr/bin/$$i ; \
+       done
+       for i in ssh-keysign ssh-pkcs11-helper ; do \
+               rm -f $(TARGET_DIR)/usr/libexec/$$i ; \
+       done
+endef
+OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_REMOVE_CLIENT
+endif
+
+ifneq ($(BR2_PACKAGE_OPENSSH_SERVER),y)
+define OPENSSH_REMOVE_SERVER
+       rm -f $(TARGET_DIR)/usr/sbin/sshd
+       rm -f $(TARGET_DIR)/usr/libexec/sftp-server
+       rm -f $(TARGET_DIR)/etc/init.d/S50sshd
+endef
+OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_REMOVE_SERVER
+endif
+

package/openssh/openssh.mk define OPENSSH_INSTALL_INIT_SYSV · line 120

Quoted 10 lines
package/openssh/openssh.mk +8 -0
+ifneq ($(BR2_PACKAGE_OPENSSH_KEY_UTILS),y)
+define OPENSSH_REMOVE_KEY_UTILS
+       for i in ssh-keygen ssh-keyscan ; do \
+               rm -f $(TARGET_DIR)/usr/bin/$$i ; \
+       done
+endef
+OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_REMOVE_KEY_UTILS
+endif
 
 $(eval $(autotools-package))

Any comments on this patch?

Thanks,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200418/fd62ac27/attachment.html>

#2 lore raw

PATCH 1/1 package/openssh: allow separate selection of client, server, keyutils

In reply to Thomas De Schampheleire

El lun., 6 abr. 2020 a las 15:56, Thomas De Schampheleire (<[email protected]>) escribi?:

Quoted 83 lines

From: Thomas De Schampheleire <[email protected]>

The openssh package comprises three separate entities: the SSH client, SSH server, and some SSH key utilities. One may want the client but not the server, the server but not the client, or maybe only the key utilities.

Add separate options for each entity and update the files installed on target accordingly.

On an ARM Cortex-A53 configuration, size of stripped binaries are:

Client programs: 2213118 bytes (2161 KB)
usr/bin/ssh,657180
usr/bin/scp,99836
usr/bin/ssh-add,312800
usr/bin/ssh-agent,296428
usr/libexec/ssh-keysign,398908
usr/libexec/ssh-pkcs11-helper,292316
usr/bin/sftp,144992
usr/bin/ssh-copy-id,10658

Server programs: 806840 bytes (787 KB)
usr/libexec/sftp-server,112140
usr/sbin/sshd,694168
etc/init.d/S50sshd,532

Key utilities: 789648 bytes (771 KB)
usr/bin/ssh-keygen,398924
usr/bin/ssh-keyscan,390724

---
 package/openssh/Config.in  | 23 +++++++++++++++++++++++
 package/openssh/openssh.mk | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 1 deletion(-)
package/openssh/Config.in +23 -0
index 683a9c0e51..cc5998742e 100644
@@ -9,3 +9,26 @@ config BR2_PACKAGE_OPENSSH
          friends.
 
          http://www.openssh.com/
+
+if BR2_PACKAGE_OPENSSH
+
+config BR2_PACKAGE_OPENSSH_CLIENT
+       bool "client"
+       default y
+       help
+         Client programs: ssh, scp, sftp, ssh-agent, ssh-add,
+         ssh-copy-id.
+
+config BR2_PACKAGE_OPENSSH_SERVER
+       bool "server"
+       default y
+       help
+         Server programs: sshd, sftp-server
+
+config BR2_PACKAGE_OPENSSH_KEY_UTILS
+       bool "key utilities"
+       default y
+       help
+         Key utilities: ssh-keygen, ssh-keyscan.
+
+endif
package/openssh/openssh.mk +2 -1
index d50572128a..b0259de7dd 100644
@@ -82,10 +82,39 @@ define OPENSSH_INSTALL_INIT_SYSV
                $(TARGET_DIR)/etc/init.d/S50sshd
 endef
 
+ifeq ($(BR2_PACKAGE_OPENSSH_CLIENT),y)
 define OPENSSH_INSTALL_SSH_COPY_ID
        $(INSTALL) -D -m 755 $(@D)/contrib/ssh-copy-id $(TARGET_DIR)/usr/bin/ssh-copy-id
 endef
-
 OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_INSTALL_SSH_COPY_ID
+else

package/openssh/openssh.mk define OPENSSH_INSTALL_INIT_SYSV · line 100

Quoted 10 lines
package/openssh/openssh.mk +10 -0
+define OPENSSH_REMOVE_CLIENT
+       for i in ssh scp sftp ssh-agent ssh-add ; do \
+               rm -f $(TARGET_DIR)/usr/bin/$$i ; \
+       done
+       for i in ssh-keysign ssh-pkcs11-helper ; do \
+               rm -f $(TARGET_DIR)/usr/libexec/$$i ; \
+       done
+endef
+OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_REMOVE_CLIENT
+endif

I discovered a problem with this approach: if dropbear is selected, and openssh without its 'client', then the dropbear tools ssh and scp will also be removed (assuming dropbear was built before openssh).

I need to think about a good solution, basically not copying the files to the target dir in the first place. But it means a custom install rule.

Quoted 23 lines
package/openssh/openssh.mk +18 -1
+
+ifneq ($(BR2_PACKAGE_OPENSSH_SERVER),y)
+define OPENSSH_REMOVE_SERVER
+       rm -f $(TARGET_DIR)/usr/sbin/sshd
+       rm -f $(TARGET_DIR)/usr/libexec/sftp-server
+       rm -f $(TARGET_DIR)/etc/init.d/S50sshd
+endef
+OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_REMOVE_SERVER
+endif
+
+ifneq ($(BR2_PACKAGE_OPENSSH_KEY_UTILS),y)
+define OPENSSH_REMOVE_KEY_UTILS
+       for i in ssh-keygen ssh-keyscan ; do \
+               rm -f $(TARGET_DIR)/usr/bin/$$i ; \
+       done
+endef
+OPENSSH_POST_INSTALL_TARGET_HOOKS += OPENSSH_REMOVE_KEY_UTILS
+endif
 
 $(eval $(autotools-package))
--

2.24.1