[SOLVED] Is telnet to OSGI console possible on OH2?

while thinking about how to allow access to the OSGI console of my OH2 installation, I stumbled on the posting about Dropbox authentication: OSGi console Dropbox Authentication

It seems that a telnet connection to the console is (or was?) available in OH1. Is this available in OH2 as well? If not, how could I gain access to the console of OH2 running as a system service?

Since OH2 uses Apache Karaf as the OSGi container, then you can ssh to it instead of telnet.

But in OH 1 Telnet does not work in Windows. Right?

Does it already? I had the impression that the karaf branch is still under development / review and that the current snapshot is still based on eclipse equinox.

On the other hand, I have no real clue about OSGI, so take whatever I write with a huge block of salt.

It looked to me like the Karaf changeover had been merged into OH2 recently, but maybe I misread it.

Its possible to enable telnet. just modify your startup script to include:

-console <telnet port>

In the startup arguments on the bottom. I’m pretty sure that is how it used to work in OH 1 as well.

For windows you usually have to go to add/remove features and enable telnet client.

Thank you for the hint, did work perfectly on my installation.

Regards,
Hakan

Actually: Which port can I use to access the karaf console via ssh it is 8101, right?

I have tried to add the paramter -console 5555 to the file openhab2/runtime/karaf/karaf

But no access via telnet is possible. I wouldn’t mind as long as SSH would work…
Is it maybe due to the fact that I started via start.sh?
Then my shell terminated and I tried to access the still running server via a new shell

$ ssh karaf@localhost -p 8101
Password authentication
Password:  <entered karaf>

-------------------------------------------------------------------------
Welcome to openHAB 2.0.0-SNAPSHOT
-------------------------------------------------------------------------

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown openHAB.

openhab>
1 Like

Unfortunately not.

Thing is: I started a ssh shell to my raspi. There I started OH2 via the start script (and the script opens the karaf console). Then the connection was terminated and I opend a new shell.

There I tried command: ssh karaf@localhost -p 8101 -> and the connection timed out after 120s

Received disconnect from 127.0.0.1: 2: Session has timed out waiting for authentication after 120000 ms.

But no authentication challenge was sent…

Any chance this subject is related?

Nope I don’t think so. I have even tried to ssh into a running OH2 Server via a second shell. The connection times out. I have modified the startup parameter to avoid opening the local console, but no change.

These are the startup parameters…

/usr/bin/java -Dopenhab.home=/opt/openhab2 -Dopenhab.conf=/opt/openhab2/conf -Dopenhab.runtime=/opt/openhab2/runtime -Dopenhab.userdata=/opt/openhab2/userdata -Dorg.osgi.service.http.port=8080 -Dorg.osgi.service.http.port.secure=8443 -Xmx256m -Djava.endorsed.dirs=/usr/lib/jvm/java-8-oracle/jre/jre/lib/endorsed:/usr/lib/jvm/java-8-oracle/jre/lib/endorsed:/opt/openhab2/runtime/karaf/lib/endorsed -Djava.ext.dirs=/usr/lib/jvm/java-8-oracle/jre/jre/lib/ext:/usr/lib/jvm/java-8-oracle/jre/lib/ext:/opt/openhab2/runtime/karaf/lib/ext -Dkaraf.instances=/opt/openhab2/runtime/karaf/instances -Dkaraf.home=/opt/openhab2/runtime/karaf -Dkaraf.base=/opt/openhab2/userdata -Dkaraf.data=/opt/openhab2/userdata -Dkaraf.etc=/opt/openhab2/runtime/karaf/etc -Djava.io.tmpdir=/opt/openhab2/userdata/tmp -Djava.util.logging.config.file=/opt/openhab2/userdata/etc/java.util.logging.properties -Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true -classpath /opt/openhab2/runtime/karaf/lib/boot/org.apache.karaf.diagnostic.boot-4.0.3.jar:/opt/openhab2/runtime/karaf/lib/boot/org.apache.karaf.jaas.boot-4.0.3.jar:/opt/openhab2/runtime/karaf/lib/boot/org.apache.karaf.main-4.0.3.jar:/opt/openhab2/runtime/karaf/lib/boot/org.osgi.core-6.0.0.jar org.apache.karaf.main.Main -console 5555

OK, any chance your systems have DNS name resolution (or reverse) problems?

Indeed! ssh karaf@127.0.0.1 -p 8101 did work finally! “localhost” does not…

1 Like

Hey,

think i’am trying the same right know.

Doing everything via SSH into Raspberry via Public-Key (OH2 running on that raspberry :D)

Normally running OH2 on Raspberry via service (systemctl) automatically at system startup. So when i ssh into the raspberry i don’t have any karaf console (do have if i ssh into raspberry and then start OH2 manuell via the start script. But then, if i’am killing the ssh session into raspberry, also OH2 is killed.)

If i ssh into raspberry and then using “ssh karaf@localhost -p 8101” it works.

But is there also a way directly shh into karaf from remote, without first ssh into raspberry? If i’am trying to “ssh karaf@ipofraspberry -p 8101” i get “Connection refused”. Think that because of the public-key i’am using?

On the mac i have some alias to ssh into raspberry. Works perfectly.

alias rpi2=“ssh rpi2”
alias olog=“ssh rpi2 ‘tail -f /opt/openhab/userdata/logs/openhab.log’”
alias elog=“ssh rpi2 ‘tail -f /opt/openhab/userdata/logs/events.log’”

Would be nice to have a alias also for karat-console. Like (but without any password-promt).

alias karaf=“ssh rpi2 ‘ssh karaf@localhost -p 8101’”

But that didn’t worked out:

Pseudo-terminal will not be allocated because stdin is not a terminal.
Host key verification failed.

Andi

Did you ever find a way to get the karaf console opened without any password-promt?

The following thread:

explains how you can change the password prompt to a SSH key based setup.

1 Like

Hi where is the startup script placed to add the -console in

im using Ubuntu to OH 2