Unison Help

- Unison Kernel
- Pthreads
- pthread_create()
- pthread_exit()
- pthread_self()
- pthread_equal()
- pthread_join()
- pthread_detach()
- pthread_setschedparam()
- pthread_getschedparam()
- pthread_attr_init()
- pthread_attr_destroy()
- pthread_attr_setstackaddr()
- pthread_attr_getstackaddr()
- pthread_attr_setstacksize()
- pthread_attr_getstacksize()
- pthread_attr_setschedparam()
- pthread_attr_getschedparam()
- pthread_attr_setdetachstate()
- pthread_attr_getdetachstate()
- pthread_stackinfo()
- pthread_setprio()
- pthread_getprio()
- sched_get_priority_max()
- sched_get_priority_min()
- sched_yield()
- Pthread Cancellation
- Mutex
- Semaphores
- Message Queues
- Conditional Variables
- Barriers
- Timers
- Clocks
- Memory Allocation
- Rendezvous
- Interrupts
- Directory Services
- Miscellaneous
- Pthreads
- Unison I/O Library
- Unison STDIO Library
- STDIO Library Calls
- clearerr()
- dprintf()
- fclose()
- fdopen()
- feof()
- ferror()
- fileno()
- fflush()
- fgetc()
- fgetpos()
- fgets()
- fopen()
- fprintf()
- fputc()
- fputs()
- fread()
- freopen()
- fscanf()
- fseek()
- fseeko()
- fsetpos()
- ftell()
- ftello()
- fwrite()
- getc()
- getc_unlocked()
- getchar()
- getchar_unlocked()
- getdelim()
- getline()
- gets()
- get_stderr_ptr()
- get_stdin_ptr()
- get_stdout_ptr()
- noperprintf()
- perprintf()
- perror()
- posix_compat()
- printf()
- putc()
- putc_unlocked()
- putchar()
- putchar_unlocked()
- puts()
- remove()
- rewind()
- scanf()
- setbuf()
- setvbuf()
- snprintf()
- sprintf()
- sscanf()
- stderr_init()
- stderr_close()
- stdin_init()
- stdin_close()
- stdout_init()
- stdout_close()
- vdprintf()
- vscanf()
- vsscanf()
- vfscanf()
- vprintf()
- vsnprintf()
- vsprintf()
- vfprintf()
- ungetc()
- Do-nothing Stubs
- STDIO Library Calls
- Unison LIBC Library
- Unison I/O Servers
- Graphics, Camera, Video, Audio
- Network Protocols
- TCP and UDP Server - tcpd
- DHCP Client Service - dhcp client
- DHCP Server - dhcpd
- Telnet Server - telnetd
- Tiny FTP Server - tftpd
- Point to Point - pppd
- Network Translation - NAT with PAT
- Firewall
- Tiny HTTP Server - thttpd
- Tiny HTTP Server with TLS
- POP3 Server
- Simple Mail Transfer Protocol Services (SMTP)
- Bootp Protocol
- File Transfer Protocol Server (FTP)
- File Transfer Client Services
- RPC / XDR
- DNS Client
- HTTP/HTTPS Client
- REST Client
- AutoIP Service - autoip client
- mDNS server - mdnsd
- SNTP Client
- SNMP Agent - Snmpd server
- SSL/TLS library
- SSH server
- IP security
- Power Control
- Serial I/O
- System Services
- Universal Serial Bus (USB)
- Wireless
- Remedy Tools for Unison
7.25. SSH server #
NAME
SSH Server – sshd
SYNOPSIS
#include <posh_init.h>
#include <login.h>
#include <ssh.h>
#include <sys.h>
- sshd(SSH_CONFIG_FILE, &shell_init);
DESCRIPTION
The SSH server provides a network ssh protocol and utilizes the vtty server technology and the posh shell server for user interaction via ssh client. Typically, when initialized, it allows users to query files, examine the file structure, create new files and look at the content of files, all over the network. It is a minimal implementation for memory reasons. It does not support terminal formating of any kind and only supports the absolute minimal set of commands.
The SSH server uses public-key cryptography to authenticate the remote computer and allow it to authenticate the user, if necessary. There are several ways to use SSH; one is to use automatically generated public-private key pairs to simply encrypt a network connection, and then use password authentication to log on. Another is to use a manually generated public-private key pair to perform the authentication, allowing users or programs to log in without having to specify a password.
SSH server allows Privete/Public Key or Password Authentication. Authentication automatic selects on connection procedure. SSH server support AES128 and 3-DES encription and SHA-1 cryptographic hash function.
SSH server support IPv4 and IPv6 protocols
For reduce memory usage SSH can suport only one POSH session.
SSH server sturtup function (sshd) have 2 parameters:
void sshd(char *config_path, tshell_init * shell);
config_path – string constatn defines path to configuration file. Structure of this file described below
shell – pointers to comfiguration functiond for POSH and/or SFTP sever. At least one funstion must be defined
SSH CONFIGURATION FILE STRUCTURE
Option | Default | Description |
---|---|---|
ipv4 | 22 | Iincoming port for IPv4 protocol. If defined -1 – protocol unsupported |
ipv6 | -1 | Incoming port for IPv4 protocol. If defined -1 – protocol unsupported |
keyfile | —- | Path for host key file. Support DSS an RSA format
Can be specified several times for different files |
rcv_window | 4096 | Recive window size |
keepalivee_timeout | 0 (forewer) | Max wait time (sec) while session can be openned. After this time connection will be closed |
idle_timeout | 0 (forewer) | Max wait time (sec) while session can be openned without data transfer. After this time connection will be closed |
loginfile | “/dev/fd/ssh/ssh_loginfile” | Path for file with logins |
authkeys_file | “/dev/fd/ssh/authorized_keys” | Path for file with keys |
posh_ena | 1 | Enabel posh connection |
sftp_ena | 0 | Enabel SFTP connection |
SSH CONFIGURATION FILE EXAMPLE
char * config_file_str = "ipv4:22\n\r" \ "ipv6:22\n\r" \ "keepalivee_timeout:1000\n\r" \ "rcv_window:1024\n\r" \ "keyfile:/dev/rd/d1/id_rsa\n\r" \ "loginfile:/dev/rd/d1/ssh_users\n\r"\ "authkeys_file:/dev/rd/d1//dev/rd/d1/id_rsa\n\r" \ "posh:1\n\r";
keyfile: path for private server host key file; This filecan be generated by “hostkeygen” utility under Linux.
hostkeygen-t rsa -f hostkey
loginfile: path for login file;
authkeys_file: path for public keys file. This file has public keys separated by ne line (one key per line);
All public keys have OpenSSH format like this:
(the text is all one, without linebreaks):
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAmihVmFR3GH8V0BmN0uexjxmCMenVrYUQ8OKYUntz 7knmxE1Wzxy1ZF6unK36GXJAxEekK1WdSXXEEB50FLcVgbfQRoTo3RBVEP2acXyvTM5R3n5GRhXl tEUVlkK5vL98f2xpQK5cqmu9+jFz/z/BdXycORb5cO6m28TDLRD+9Fk= rsa-key-20050927
SSH initialization structure
typedef struct { int (*posh_start)(void *); int (*sftp_start)(void *); } tshell_init;
Posh initialization structure.
struct set_posh { char *stdinstring; // set the input stream char *stdoutstring; // set output stream char *mountpoint; // set first file mount point char *mountpoint2; // set second file mount point char *loginfile; };
This partial example shows the creation and registration of the SSH server and its associated vtty file I/O. After creation, posh is created which interacts via the vtty file I/O ports for input and output.
int start_posh(void * arg); THREAD ssh_shell(void *arg) { tshell_init shell_init; shell_init.posh_start = start_posh; shell_init.sftp_start = NULL; sshd(SSH_CONFIG_FILE, &shell_init); return 0; //just to avoid warning } ... int start_posh(void) { struct set_posh *set_posh_tty; pthread_t poshTid; pthread_attr_t poshattr; struct sched_param poshPriority; if( (set_posh_tty = malloc(sizeof(struct set_posh)))==NULL) { xprintf("posh create - no memory\n"); return -1; } set_posh_tty->stdinstring = "/dev/sshtty0"; set_posh_tty->stdoutstring = "/dev/sshtty0"; set_posh_tty->mountpoint = FSYS_MOUNT; set_posh_tty->mountpoint2 = NULL; set_posh_tty->loginfile = SSH_LOGIN_FILE; set_posh_tty->flags = POSH_LOGIN_DIS | VTTY_CONNECTION; pthread_attr_init(&poshattr); pthread_attr_setstacksize(&poshattr, 1400); poshPriority.sched_priority = 5; pthread_attr_setdetachstate(&poshattr, PTHREAD_CREATE_DETACHED); pthread_attr_setschedparam(&poshattr, &poshPriority); pthread_create(&poshTid, &poshattr, (void *(*)(void*))posh, set_posh_tty); pthread_attr_destroy(&poshattr); return 0; /* * Start ssh example */ ... pthread_attr_init(&attr); myNewPriority.sched_priority = 6; pthread_attr_setschedparam(&attr, &myNewPriority); pthread_attr_setstacksize(&attr, 8196); if(pthread_create(&pid, &attr, &ssh_shell, 0)!=0) { xprintf("pthread_create = %d\n", errno); #if RTOS_DEBUG dir_deregister("Main thread"); #endif pthread_exit(0); } pthread_attr_destroy(&attr); ...
SSH – POSH COMMANDS AND OPTIONS
- help – help listing
- alias [alias_name=”value”] – setup an alias for an expression
- cat – concatenate output
- cd <dir> – change directory to <dir>
- chmod <mode> <dir | file> – change a file’s access control mode
mode – file access mode, for example “rwx”
dir | file – path to the target file to which mode is setting
- cp <src> <dst> – copy a file from <src> path to <dst> path
- exit – exit the posh shell
- ln <src> <dst> – create link to file
src – target path for link
dst – link name (with path)
- logout – logout of posh
- ls [option] – list directory contents
-l – for long list
-d – lists directories, not content
- mkdir <dir> – make a directory specified by <dir>
- mv <src> <dst> – move a file from <src> path to <dst> path
- printenv [env_name] – print all or part of environment
printenv [VARIABLE] or printenv OPTION
If VARIABLE or OPTION not specified, then all present will be printed
- pwd – present working directory
- rm <file> – remove a file
- rmdir – remove a directory
- setenv [env_name=”value”] – set an environment variable
Example: setenv PATH “/d0:/sd/d1:/sd/d1/d2”
- unalias <alias_name> – delete an alias
- useradd <username> <password> – add a user with a password
- userdel <username> – delete a user
- userpasswd <username> <oldpassword> <newpassword> – set (or reset) a user password
NOTES
There is a demo available for the Unison and DSPnano SSH server which is found in installdir/demos.