2016-06-11 10:48:53 +00:00
---
layout: documentation
2017-01-18 16:50:32 +00:00
title: The Console
2016-06-11 10:48:53 +00:00
---
{% include base.html %}
2017-01-18 16:50:32 +00:00
# The Console
2016-06-11 10:48:53 +00:00
2020-12-28 08:16:12 +00:00
The console offers the ability to:
2016-06-11 10:48:53 +00:00
2017-03-18 12:05:00 +00:00
* Monitor the [log ](logging.html#karaf-console ) in realtime
* Manage [bundles ](bundles.html )
* Execute [runtime commands ](runtime.html )
2016-06-11 10:48:53 +00:00
2017-01-18 16:50:32 +00:00
## Accessing the Console
2016-06-11 10:48:53 +00:00
2020-12-28 08:16:12 +00:00
The method used to access the console depends on how openHAB was started.
2016-06-11 10:48:53 +00:00
2017-12-16 23:57:32 +00:00
* When started in interactive mode using the provided command line scripts (e.g. `start.sh` or `start.bat` ), openHAB naturally transitions directly to the console prompt.
* When started as a service (i.e. when openHAB is running as a background process), access to the console is given by running the `$OPENHAB_RUNTIME/bin/client` (`client.bat` for Windows) script or by [connecting via SSH ](#connecting-via-ssh ).
Linux package based installations can also use the command `openhab-cli console` .
2016-06-11 10:48:53 +00:00
2017-12-16 23:57:32 +00:00
The default username/password is **openhab:habopen** , so enter `habopen` at the password prompt.
### Connecting via SSH
2020-12-28 08:16:12 +00:00
The console can also be reached via a secure shell ([SSH](https://en.wikipedia.org/wiki/Secure_Shell)) connection.
2017-03-18 12:05:00 +00:00
To reach the console using SSH, use the following command to connect to the localhost interface on TCP port 8101:
```shell
ssh -p 8101 openhab@localhost
```
2019-12-27 15:18:48 +00:00
::: tip Note
2020-12-28 08:16:12 +00:00
By default, connections are only allowed from localhost, i.e. only from the machine running openHAB.
2017-03-18 12:05:00 +00:00
Connections are intentionally not allowed from remote hosts due to security concerns.
To change this, see [Bind Console to All Interfaces ](#bind-console-to-all-interfaces ).
2019-12-27 15:18:48 +00:00
:::
2017-03-18 12:05:00 +00:00
A security warning is expected upon the first connection:
```text
The authenticity of host '[localhost]:8101 ([127.0.0.1]:8101)' can't be established.
RSA key fingerprint is SHA256:XjQxBPit+K5m3HuSsEUI/842NTCxLTu3EMGGBuQKNVg.
Are you sure you want to continue connecting (yes/no)?
2016-06-11 10:48:53 +00:00
```
2017-03-18 12:05:00 +00:00
Enter `yes` to proceed.
```text
Warning: Permanently added '[localhost]:8101' (RSA) to the list of known hosts.
2016-06-11 10:48:53 +00:00
Password authentication
2017-01-18 16:50:32 +00:00
Password:
2017-03-18 12:05:00 +00:00
```
The default username/password is **openhab:habopen** , so enter `habopen` at the password prompt.
2016-06-11 10:48:53 +00:00
2017-03-18 12:05:00 +00:00
The first successful connection triggers generation of the Karaf remote console key and will take a few seconds longer than subsequent attempts.
2019-12-27 15:18:48 +00:00
::: tip Note
On slower systems, such as Raspberry Pi or Pine64, this first SSH connection may even time out.
2017-03-18 12:05:00 +00:00
If this happens, simply try connecting again until successful.
2019-12-27 15:18:48 +00:00
:::
2017-03-18 12:05:00 +00:00
2017-12-16 23:57:32 +00:00
## Using the Console
2017-03-18 12:05:00 +00:00
After successful connection and authentication, the console will appear:
```text
2020-12-28 08:16:12 +00:00
_ _ _ ____
___ ___ ___ ___ | | | | / \ | __ )
/ _ \ / _ \ / _ \ / _ \ | |_| | / _ \ | _ \
| (_) | (_) | __ /| | | || _ | / ___ \ | |_) )
\___/| __ / \___/|_| |_||_| |_|/_/ \_\|____/
|_| 3.0.0 - Release Build
Use '< tab > ' for a list of available commands
2016-06-11 10:48:53 +00:00
and '[cmd] --help' for help on a specific command.
2020-12-28 08:16:12 +00:00
To exit, use '< ctrl-d > ' or 'logout'.
2016-06-11 10:48:53 +00:00
openhab>
```
2017-03-18 12:05:00 +00:00
The command `help` is listing all available commands or describes a specific subsystem/command:
2016-06-11 10:48:53 +00:00
2017-03-18 12:05:00 +00:00
```text
2016-06-11 10:48:53 +00:00
openhab> help
2017-03-18 12:05:00 +00:00
...
2016-06-11 10:48:53 +00:00
openhab> help bundle
...
openhab> help bundle:stop
...
```
2017-01-18 16:50:32 +00:00
The console also supports auto-completion during input.
2017-03-18 12:05:00 +00:00
Auto-completion proposes possible commands based on the current input and is triggered by a < TAB> press on your keyboard.
So for example entering "*bund*" and pressing the < TAB> key will first extend to the only viable candidate "bundle", a subsequent < TAB> press will result in:
2016-08-02 09:35:18 +00:00
2017-03-18 12:05:00 +00:00
```text
2016-08-02 09:35:18 +00:00
openhab> bundle
2017-01-18 16:50:32 +00:00
bundle bundle:capabilities bundle:classes bundle:diag bundle:dynamic-import
bundle:find-class bundle:headers bundle:id bundle:info bundle:install
bundle:list bundle:load-test bundle:refresh bundle:requirements bundle:resolve
bundle:restart bundle:services bundle:start bundle:start-level bundle:stop
bundle:tree-show bundle:uninstall bundle:update bundle:watch
```
2016-08-02 09:35:18 +00:00
2017-03-18 12:05:00 +00:00
Another useful feature is the combination of the `|` (pipe) and `grep` functionality, which can be used to filter output:
2016-08-02 09:35:18 +00:00
2017-03-18 12:05:00 +00:00
```text
2016-08-02 09:35:18 +00:00
openhab> bundle:list | grep openHAB
2020-12-28 08:16:12 +00:00
128 x Active x 80 x 3.0.0 x openHAB Core :: Bundles :: Core
129 x Active x 80 x 3.0.0 x openHAB Core :: Bundles :: Audio
130 x Active x 80 x 3.0.0 x openHAB Core :: Bundles :: JAAS Authentication
131 x Active x 80 x 3.0.0 x openHAB Core :: Bundles :: OAuth2Client
132 x Active x 80 x 3.0.0 x openHAB Core :: Bundles :: Automation
...
2016-08-02 09:35:18 +00:00
```
2017-01-18 16:50:32 +00:00
The session is ended by using the logout command:
2016-06-11 10:48:53 +00:00
2017-03-18 12:05:00 +00:00
```text
2016-06-11 10:48:53 +00:00
openhab> logout
```
2020-12-28 08:16:12 +00:00
Learn about all of the available commands by using the `help` command.
2017-03-18 12:05:00 +00:00
## Modifying the Console Settings
Changing the console password, interface, and port is described here.
### Console Settings Files and Directories
The pertinent files controlling console settings are stored under `$OPENHAB_USERDATA/etc/` :
| File | Purpose |
|------------------------------|--------------------------------|
| `org.apache.karaf.shell.cfg` | Controls most console settings |
| `users.properties` | Stores console password |
2020-12-25 14:53:40 +00:00
The exact locations of these files will vary based on your platform and installation method, e.g. `/var/lib/openhab/etc/` or `openhab/userdata/etc/` .
2017-03-18 12:05:00 +00:00
2017-11-23 23:12:40 +00:00
Be aware that the these files may get overwritten when upgrading openHAB.
2020-12-25 14:53:40 +00:00
To add custom parameters or overwrite the default values, you can change the configuration file `runtime.cfg` which can be found in the `$OPENHAB_CONF/services` directory, e.g. `/etc/openhab/services/runtime.cfg` .
2017-11-23 23:12:40 +00:00
2017-03-18 12:05:00 +00:00
### Changing the Password
The password is stored in the file `users.properties` , located in the `etc` directory as [mentioned above ](#console-settings-files-and-directories ).
2021-01-10 12:50:59 +00:00
By default, the line with the password contains the text `openhab =` , followed by the current password (e.g. `habopen` ) or a password hash (e.g. `{CRYPT}4AE1A0FD...{CRYPT}` ).
2017-03-18 12:05:00 +00:00
To change the authentication password edit the file manually, replacing the password or password hash (including `{CRYPT}` ) with your new password in clear text.
Alternately, run the following Linux shell command, which will perform the replacement for you.
Substitute `securePassword` with your desired password.
```shell
2020-12-25 14:53:40 +00:00
sudo sed -i -e "s/openhab = .*,/openhab = securePassword,/g" /var/lib/openhab/etc/users.properties
2017-03-18 12:05:00 +00:00
```
Depending on your system, you may have to [change the directory ](#console-settings-files-and-directories ) at the end of the command.
Please restart openHAB for the changes to take effect. The clear text password will be replaced by a unique cryptographic password hash.
2016-07-16 19:50:38 +00:00
2017-03-18 12:05:00 +00:00
### Bind Console to All Interfaces
2016-11-12 18:28:23 +00:00
2017-03-18 12:05:00 +00:00
The network interface configuration is defined in the file `org.apache.karaf.shell.cfg` , located in the `etc` directory as [mentioned above ](#console-settings-files-and-directories ).
2020-12-25 14:53:40 +00:00
As this file may get overwritten when upgrading openHAB, you can change this parameter in the `runtime.cfg` file which can be found in the `$OPENHAB_CONF/services` directory, e.g. `/etc/openhab/services/runtime.cfg` .
2017-11-23 23:12:40 +00:00
2017-03-18 12:05:00 +00:00
The `sshHost` entry controls the interface address to bind to.
`sshHost = 127.0.0.1` (localhost) is the default due to obvious security reasons.
2020-12-28 08:16:12 +00:00
If you are on a secure network or you are fully aware of all of the risks of exposing your system to the public, you can change the bind address.
2017-03-18 12:05:00 +00:00
Replace the `sshHost` IP `127.0.0.1` by `0.0.0.0` to bind to all available network interfaces.
2020-12-28 08:16:12 +00:00
Please be aware that the console will now be accessible from all devices in your subnet and only secured by the password defined in `users.properties` (same path).
You should therefore [change the password ](#changing-the-password )!
2017-11-23 23:12:40 +00:00
Depending on your network configuration the console may also be exposed to the public internet, so check your routing and firewall configuration.
2016-06-30 19:16:11 +00:00
2017-11-23 23:12:40 +00:00
To enable binding to all interfaces, uncomment the line
2017-03-18 12:05:00 +00:00
2017-11-23 23:12:40 +00:00
```#org.apache.karaf.shell:sshHost = 0.0.0.0```
in `services/runtime.cfg` .
2019-12-27 15:18:48 +00:00
2017-03-18 12:05:00 +00:00
### Change the Port Number
The SSH port configuration is done through the file `org.apache.karaf.shell.cfg` , located in the `etc` directory as [mentioned above ](#console-settings-files-and-directories ).
The `sshPort` entry controls the port number.
2020-12-28 08:16:12 +00:00
`sshPort = 8101` is the default, but can be changed to any available port of your choosing.
2017-03-18 12:05:00 +00:00
Alternately, run the following Linux shell command, which will perform the replacement for you.
Substitute `1234` with your desired port number.
Depending on your system, you may have to substitute [the directory ](#console-settings-files-and-directories ) at the end of the command.
```shell
2020-12-25 14:53:40 +00:00
sudo sed -i -e "s/sshPort = .*/sshPort = 1234/g" /var/lib/openhab/etc/org.apache.karaf.shell.cfg
2016-06-30 19:16:11 +00:00
```
2017-03-18 12:05:00 +00:00
----
2016-06-30 19:16:11 +00:00
2020-12-21 09:13:16 +00:00
Please check the [Apache Karaf reference ](https://karaf.apache.org/manual/latest/ ) for more details.