mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
netutils/dropbear: add Dropbear SSH server port for NuttX
Integrated SSH daemon authenticating against FSUTILS_PASSWD, with an ECDSA P-256 host key and an NSH session over a PTY per connection. Built from the upstream Dropbear tarball (pinned commit) and patched for NuttX, using Dropbear's bundled libtomcrypt for all crypto. setsid() (apache/nuttx#19184) and link() now come from NuttX, not local stubs. Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
This commit is contained in:
parent
e44c4f370f
commit
fee2ddbf54
24 changed files with 2449 additions and 1 deletions
|
|
@ -101,6 +101,10 @@ if(CONFIG_NSH_LIBRARY)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_NSH_DROPBEAR)
|
||||
list(APPEND CSRCS nsh_dropbear.c)
|
||||
endif()
|
||||
|
||||
if(NOT CONFIG_NSH_DISABLESCRIPT)
|
||||
list(APPEND CSRCS nsh_test.c)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -1201,6 +1201,28 @@ config NSH_DISABLE_TELNETSTART
|
|||
|
||||
endmenu # Telnet Configuration
|
||||
|
||||
menu "Dropbear Configuration"
|
||||
|
||||
config NSH_DROPBEAR
|
||||
bool "Start Dropbear SSH server"
|
||||
default n
|
||||
depends on NETUTILS_DROPBEAR
|
||||
depends on NSH_BUILTIN_APPS
|
||||
depends on !NSH_DISABLEBG
|
||||
select NSH_LOGIN
|
||||
---help---
|
||||
If NSH_DROPBEAR is set to 'y', then NSH starts the Dropbear SSH
|
||||
server automatically.
|
||||
|
||||
config NSH_DISABLE_DROPBEARSTART
|
||||
bool "Disable to start Dropbear"
|
||||
default n
|
||||
depends on NSH_DROPBEAR
|
||||
---help---
|
||||
Determines if NSH starts Dropbear automatically.
|
||||
|
||||
endmenu # Dropbear Configuration
|
||||
|
||||
config NSH_LOGIN
|
||||
bool
|
||||
default n
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ CSRCS += nsh_telnetlogin.c
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_DROPBEAR),y)
|
||||
CSRCS += nsh_dropbear.c
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_NSH_DISABLESCRIPT),y)
|
||||
CSRCS += nsh_test.c
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -844,6 +844,10 @@ int nsh_login(FAR struct console_stdio_s *pstate);
|
|||
int nsh_telnetlogin(FAR struct console_stdio_s *pstate);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NSH_DROPBEAR) && !defined(CONFIG_NSH_DISABLE_DROPBEARSTART)
|
||||
int nsh_dropbearstart(void);
|
||||
#endif
|
||||
|
||||
/* Application interface */
|
||||
|
||||
int nsh_command(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char *argv[]);
|
||||
|
|
|
|||
76
nshlib/nsh_dropbear.c
Normal file
76
nshlib/nsh_dropbear.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/****************************************************************************
|
||||
* apps/nshlib/nsh_dropbear.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "nsh.h"
|
||||
#include "nsh_console.h"
|
||||
|
||||
#ifdef CONFIG_NSH_DROPBEAR
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_dropbearstart
|
||||
*
|
||||
* Description:
|
||||
* nsh_dropbearstart() starts the Dropbear SSH server. This function
|
||||
* returns immediately after the daemon has been started.
|
||||
*
|
||||
* Returned Values:
|
||||
* Zero is returned if Dropbear was started. A negated errno value will be
|
||||
* returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_NSH_DISABLE_DROPBEARSTART
|
||||
int nsh_dropbearstart(void)
|
||||
{
|
||||
FAR struct console_stdio_s *pstate = nsh_newconsole(false);
|
||||
char cmdline[] = CONFIG_NETUTILS_DROPBEAR_PROGNAME " &";
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(pstate != NULL);
|
||||
|
||||
ninfo("Starting the Dropbear SSH server\n");
|
||||
|
||||
ret = nsh_parse(&pstate->cn_vtbl, cmdline);
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: Failed to start Dropbear: %d\n", ret);
|
||||
}
|
||||
|
||||
nsh_release(&pstate->cn_vtbl);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NSH_DROPBEAR */
|
||||
|
|
@ -175,4 +175,16 @@ void nsh_initialize(void)
|
|||
|
||||
nsh_telnetstart(AF_UNSPEC);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NSH_DROPBEAR) && \
|
||||
!defined(CONFIG_NSH_DISABLE_DROPBEARSTART) && \
|
||||
!defined(CONFIG_NETINIT_NETLOCAL)
|
||||
/* If Dropbear is selected as an SSH front-end, then start the daemon
|
||||
* UNLESS network initialization is deferred via CONFIG_NETINIT_NETLOCAL.
|
||||
* In that case, Dropbear must be started manually with the dropbear
|
||||
* command after the network has been initialized.
|
||||
*/
|
||||
|
||||
nsh_dropbearstart();
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue