feat: Implement directory validation and shell command quoting
- Added is_valid_directory function to validate directory paths, ensuring they do not contain control characters and are within a specified length. - Introduced quote_shell_arg to safely quote shell arguments, preventing command injection. - Created build_cd_command to generate a command for changing directories in a shell. - Enhanced the LoginHandler to utilize a login rate limiter, preventing brute-force attacks by tracking failed login attempts. - Implemented an EncodingCache to optimize encoding detection for SSH connections. - Updated the UI to include an input field for specifying an initial directory upon login, with appropriate validation and hints. - Added a quickbar in the terminal interface for easy access to copy and paste functionality. - Introduced a toast notification system to provide feedback on copy actions. - Refactored connection storage to encrypt passwords at rest, improving security. - Updated various templates and styles to accommodate new features and improve user experience.
This commit is contained in:
@@ -109,7 +109,8 @@ var opts = {
|
||||
password: 'password',
|
||||
privatekey: 'the private key text',
|
||||
passphrase: 'passphrase',
|
||||
totp: 'totp'
|
||||
totp: 'totp',
|
||||
directory: '/var/www'
|
||||
};
|
||||
wssh.connect(opts);
|
||||
|
||||
@@ -169,6 +170,11 @@ Passing a command executed right after login
|
||||
http://localhost:8888/?command=pwd
|
||||
```
|
||||
|
||||
Passing an initial working directory (the shell runs `cd` right after login)
|
||||
```bash
|
||||
http://localhost:8888/?hostname=xx&username=yy&directory=/var/www
|
||||
```
|
||||
|
||||
Passing a terminal type
|
||||
```bash
|
||||
http://localhost:8888/?term=xterm-256color
|
||||
@@ -181,6 +187,11 @@ Start up the app
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Rebuild after changing the code
|
||||
```
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
Tear down the app
|
||||
```
|
||||
docker compose down
|
||||
@@ -189,6 +200,27 @@ docker compose down
|
||||
The bundled compose file persists login and saved connection data in the
|
||||
`webssh-data` volume mounted at `/data` inside the container.
|
||||
|
||||
Extra options can be passed without rebuilding the image via `WEBSSH_OPTS`:
|
||||
```
|
||||
WEBSSH_OPTS="--maxconn=50 --tdstream=172.18.0.1" docker compose up -d
|
||||
```
|
||||
|
||||
Set `--tdstream` to your reverse proxy address whenever `xheaders` is on
|
||||
(the default). Without it any client can spoof `X-Forwarded-For` and claim
|
||||
someone else's address, which defeats the per-client connection limit.
|
||||
|
||||
### Saved connections
|
||||
|
||||
Saved SSH passwords are encrypted at rest in `connections.json` with a key
|
||||
derived from the server secret, and are never sent to the browser. Leaving
|
||||
the password field empty for a saved host tells the server to use the one it
|
||||
already holds; editing the hostname, port or username makes it a different
|
||||
destination, so the stored credential is not reused there.
|
||||
|
||||
The server secret lives in `<data-dir>/cookie_secret` and can be overridden
|
||||
with the `WEBSSH_COOKIE_SECRET` environment variable. Losing it does not break
|
||||
the app, but saved passwords become unreadable and have to be entered again.
|
||||
|
||||
### Tests
|
||||
|
||||
Requirements
|
||||
|
||||
Reference in New Issue
Block a user