wolfssh/README.md

226 lines
6.9 KiB
Markdown
Raw Normal View History

2014-06-23 12:07:57 -05:00
wolfssh
=======
2016-03-31 16:12:18 -05:00
wolfSSL's Embeddable SSH Server
dependencies
------------
wolfSSH is dependent on wolfCrypt. The simplest configuration of wolfSSL
required for wolfSSH is the default build.
$ cd wolfssl
$ ./configure [OPTIONS] --enable-ssh
$ make check
$ sudo make install
To use the key generation function in wolfSSH, wolfSSL will need to be
configured with keygen: `--enable-keygen`.
If the bulk of wolfSSL code isn't desired, wolfSSL can be configured with
the crypto only option: `--enable-cryptonly`.
2016-03-31 16:12:18 -05:00
building
--------
From the source directory run:
$ ./autogen.sh
$ ./configure
$ make
$ make check
The `autogen.sh` script only has to be run the first time after cloning the
repository. If you have already run it or are using code from a source
archive, you should skip it.
For building under Windows with Visual Studio, see the file
"ide/winvs/README.md".
NOTE: On resource constrained devices the DEFAULT_WINDOW_SZ may need to be set
2019-02-08 17:40:14 -06:00
to a lower size. It can also be increased in desktop use cases to help with
large file transfers. By default channels are set to handle 16,384 bytes of data
being sent and received. An example of setting a window size for new channels
would be as follows "./configure CPPFLAGS=-DDEFAULT_WINDOW_SZ=16384"
2016-03-31 16:12:18 -05:00
examples
--------
The directory `examples` contains an echoserver that any client should be able
to connect to. From the terminal run:
$ ./examples/echoserver/echoserver
From another terminal run:
$ ssh_client localhost -p 22222
The server will send a canned banner to the client:
wolfSSH Example Echo Server
2016-03-31 16:12:18 -05:00
Characters typed into the client will be echoed to the screen by the server.
If the characters are echoed twice, the client has local echo enabled. The
echo server isn't being a proper terminal so the CR/LF translation will not
work as expected.
2016-06-16 17:50:11 -05:00
2016-06-16 17:50:11 -05:00
testing notes
-------------
After cloning the repository, be sure to make the testing private keys read-
only for the user, otherwise ssh_client will tell you to do it.
IDE Support 1. Added Windows Visual Studio build solution. Includes projects for: * wolfSSH static library * echoserver * unit-test * api-test * 32- and 64-bit debug and release builds for all 2. Made necessary tweaks including adding some wrapper functions so the code compiles for both Linux/macOS and Windows. 3. Fixed a bug in the KDF test where the output buffer wasn't updated when SHA-256 was added. 4. Added the fallthrough attribute for GCC7. 5. Replaced all uses of `uint8_t`, `uint16_t`, and `uint32_t` with the wolfCrypt provided `byte`, `word16`, and `word32`. 6. Split the new channel function into new and init. 7. Added some ECC keys for authentication testing. 8. Moved some functions and includes around. 9. Removed the keying state machine and replaced with a flag. 10. Added rekey trigger if the client sends *CTRL-F* to echoserver. 11. Moved the sequence number increase outside `CreateMac()`. Incremented if the packet was successfully created. This way the sequence number is incremented when using AES-GCM. 12. Removed the redundant function `SendText()`. 13. Renamed the `clientId` related functions and data members to `protoId` to keep things role agnostic. 14. Changed all references of `clientKey` and `serverKey` to `keys` and `peerKeys`. 15. Updated `GenerateKeys()` to generate `keys` and `peerKeys` appropriately based on the endpoint side. 16. Added the wolfSSL style _test.h_ file to group shared example functions in one place. 17. Changed the echoserver to be similar to wolfSSL's where the code may be included without the main function in another executable. Note: This commit is a squash of more than a dozen commits. IDE support was added to the client branch, but the client branch is on hold. There were many changes in the client branch that are needed going forward. The code at the head of the client branch was copied over to the IDE branch, and the client code either deleted or removed from the build.
2017-09-12 13:26:54 -05:00
$ chmod 0600 ./keys/gretel-key-rsa.pem ./keys/hansel-key-rsa.pem \
./keys/gretel-key-ecc.pem ./keys/hansel-key-ecc.pem
2016-06-16 17:50:11 -05:00
Authentication against the example echoserver can be done with a password or
public key. To use a password the command line:
$ ssh_client -p 22222 USER@localhost
Where the `USER` and password pairs are:
jill:upthehill
jack:fetchapail
To use public key authentication use the command line:
$ ssh_client -i ./keys/key-USER.pem -p 22222 USER@localhost
2016-06-16 17:50:11 -05:00
Where the user can be `gretel` or `hansel`.
2018-05-31 14:42:50 -05:00
scp support
-----------
wolfSSH includes server-side support for scp, which includes support for both
copying files 'to' the server, and copying files 'from' the server. Both
single file and recursive directory copy are supported with the default
send and receive callbacks.
To compile wolfSSH with scp support, use the `--enable-scp` build option
or define `WOLFSSL_SCP`:
$ ./configure --enable-scp
$ make
For full API usage and implementation details, please see the wolfSSH User
Manual.
The wolfSSL example server has been set up to accept a single scp request,
and is compiled by default when compiling the wolfSSH library. To start the
example server, run:
$ ./examples/server/server
Standard scp commands can be used on the client side. The following are a
few examples, where `scp` represents the ssh client you are using.
To copy a single file TO the server, using the default example user "jill":
$ scp -P 22222 <local_file> jill@127.0.0.1:<remote_path>
To copy the same single file TO the server, but with timestamp and in
verbose mode:
$ scp -v -p -P 22222 <local_file> jill@127.0.0.1:<remote_path>
To recursively copy a directory TO the server:
$ scp -P 22222 -r <local_dir> jill@127.0.0.1:<remote_dir>
To copy a single file FROM the server to the local client:
$ scp -P 22222 jill@127.0.0.1:<remote_file> <local_path>
To recursively copy a directory FROM the server to the local client:
$ scp -P 22222 -r jill@127.0.0.1:<remote_dir> <local_path>
port forwarding support
-----------------------
wolfSSH provides client side support for port forwarding. This allows the user
to set up an encrypted tunnel to another server, where the SSH client listens
on a socket and forwards connections on that socket to another socket on
the server.
To compile wolfSSH with port forwarding support, use the `--enable-fwd` build
option or define `WOLFSSH_FWD`:
$ ./configure --enable-fwd
$ make
For full API usage and implementation details, please see the wolfSSH User
Manual.
2018-12-14 15:40:38 -06:00
The portfwd example tool will create a "direct-tcpip" style channel. These
directions assume you have OpenSSH's server running in the background with
port forwarding enabled. This example forwards the port for the wolfSSL
client to the server as the application. It assumes that all programs are run
on the same machine in different terminals.
src/wolfssl$ ./examples/server/server
2018-12-14 15:40:38 -06:00
src/wolfssh$ ./examples/portfwd/portfwd -p 22 -u <username> \
-f 12345 -t 11111
src/wolfssl$ ./examples/client/client -p 12345
By default, the wolfSSL server listens on port 11111. The client is set to
2018-12-14 15:40:38 -06:00
try to connect to port 12345. The portfwd logs in as user "username", opens
a listener on port 12345 and connects to the server on port 11111. Packets
are routed back and forth between the client and server. "Hello, wolfSSL!"
2018-12-14 15:40:38 -06:00
The source for portfwd provides an example on how to set up and use the
port forwarding support in wolfSSH.
2018-11-13 11:04:47 -06:00
sftp support
2018-11-15 18:21:29 -06:00
------------
2018-11-13 11:04:47 -06:00
wolfSSH provides server and client side support for SFTP version 3. This
allows the user to set up an encrypted connection for managing file systems.
To compile wolfSSH with SFTP support, use the `--enable-sftp` build option or
define `WOLFSSH_SFTP`:
$ ./configure --enable-sftp
$ make
For full API usage and implementation details, please see the wolfSSH User
Manual.
The SFTP client created is located in the directory examples/sftpclient/ and the
2018-11-13 11:04:47 -06:00
server is ran using the same echoserver as with wolfSSH.
src/wolfssh$ ./examples/sftpclient/wolfsftp
2018-11-13 11:04:47 -06:00
A full list of supported commands can be seen with typeing "help" after a
connection.
```
wolfSSH sftp> help
Commands :
cd <string> change directory
chmod <mode> <path> change mode
get <remote file> <local file> pulls file(s) from server
ls list current directory
mkdir <dir name> creates new directory on server
put <local file> <remote file> push file(s) to server
pwd list current path
quit exit
rename <old> <new> renames remote file
reget <remote file> <local file> resume pulling file
reput <remote file> <local file> resume pushing file
<crtl + c> interrupt get/put cmd
```
An example of connecting to another system would be
src/wolfssh$ ./examples/sftpclient/wolfsftp -p 22 -u user -h 192.168.1.111