I’m having trouble to get the Karaf Console to work in Visual Studio Code.
Here is a short description of the setup I’m using:
OH2 version 2.2.0.010 is running on a Synology DS214
Visual Studio 1.23.1 running on my local Windows 10 PC with OH2 extension (0.3.5)
The OH2 Config Files are shared from the DS214 to a network drive mounted to my Win 10 PC.
VSC is accessing the Config files on the network drive on my local PC.
To access the OH Console, I am currently using PuTTY to connect to the Synology server using my local IP 192.168.2.XX with ssh on Port 22, the admin user and admin password.
Once logged into the server, I am using “ssh -p 8101 openhab@localhost” to start the OH console.
To get the Console to work I’ve done the following:
added “openhab.karafCommand”: “ssh -p 8101 openhab@localhost ‘log:tail’”, to the user settings in VSC
added “openhab.host”: “192.168.2.XX”, to user settings
PS Z:\> ssh -p 8101 openhab@localhost 'log:tail'
ssh: connect to host localhost port 8101: Connection refused
I guess my setup appears to be incomplete to be able to start the console in VSC.
What part is missing ?
What is meant by “Note that this option is available only if you exposed Karaf console.”
How do I expose the Karaf Console ?
I do not remember when it changed, but at some point a decision was made that by default karaf is setup to be accessed from the local machine only for security reasons; so to access karaf you would need to open a shell window in your NAS drive; this restriction can be changed [edit] see the docs: https://docs.openhab.org/administration/console.html#bind-console-to-all-interfaces
@lipp_markus
Thanks for your advise.
I have tried to lift the restriction to access the Karaf Console in VSC by modifying the entry in the runtime.cfg file.
I temporarily modified the entry to “org.apache.karaf.shell:sshHost = 0.0.0.0”
Rebooted the NAS, result is: connection refused:
PS Z:> ssh -p 8101 openhab@192.168.2.38 ‘log:tail’
ssh: connect to host 192.168.2.38 port 8101: Connection refused
Then I reset the Karaf entry in runtime.cfg back to the default value and rebooted the NAS:
“org.apache.karaf.shell:sshHost = 127.0.0.1”
Then I tried again the remote shell via PuTTY with this: (Remember it worked before)
login as: admin
admin@192.168.2.38's password:
admin@DS216-MD1:~$ ssh -p 8101 openhab@localhost
ssh: connect to host localhost port 8101: Connection refused
Same result: Connection refused
So basically I’m now completely stuck and can no longer access the Karaf Console.
Neither via remote shell nor via the VSC terminal.
What is wrong here ?
In the meantime I’ve got the Karaf Console via remote shell back to work.
Now trying to get it to work in VSC from my local PC.
I have set runtime.cfg to “org.apache.karaf.shell:sshHost = 0.0.0.0”
When now lauching the console I get the following message below:
> PS Z:> ssh -p 8101 openhab@192.168.2.38 ‘log:tail’
Unable to negotiate with 192.168.2.38 port 8101: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
What is the issue here ?
192.168.2.38 is the IP from the NAS server running OH2.
VSC is running on my local PC using OpenSSH Client (Beta) from Windows 10
OK, although I don’t understand each step in detail let me give it a try, but I need some help to get the steps done:
Step 1.1 is completed, file id_ed25519.pub is created
Step 1.2.1
OH2 is running on a NAS DS 214 Synology, User is “admin”
What command do you want me to perform on the remote shell ?
“ssh-copy-id -i ~/.ssh/mykey user@host” ? Is this correct ?
Step 1.2.2
I can see an .ssh folder under /var/services/homes/admin/ …
Is this the correct folder and as there is no /authorized_keys file in that folder, do you want me to create the file and copy the content from id_ed25519 into that file ?
Once you confirm, I’ll give it a try … Thanks for your help
The important thing is that home directories for SSH users MUST be writable ONLY by the user. The web UI creates these wrong. For each home directory, change permissions:
Changes permission to full (read/write/execute) for the user, but to read/execute only for the group and for everyone else
sudo chmod 755 /volume1/homes/someuser
Check on a command line on your Synology, check the pubkey
I’ve executed steps 1-3 and 5, but now receiving the message below on Synology at step 4:
admin@DS216-MD1:/$ ssh-keygen -l -f /var/services/homes/admin/.ssh/authorized_keys
/var/services/homes/admin/.ssh/authorized_keys is not a public key file.
What is the expected message here ? Is it OK to proceed ?
After some try and error I managed to get Steps 1-6 completed.
I restarted the Synology server and VSCode and executed the following command in the VSCode Terminal window:
It is asking for the openhab daemon user’s password on the Synology (which I believe I don’t have …)
I’m stuck at this point, Please advise …
BTW: the runtime.cfg file has not been modified at this point.
Still on default with “# org.apache.karaf.shell:sshHost = 0.0.0.0” commented out
Is this correct ?
Maybe you have multiple ssh clients in windows, make sure that the client which has the right path is the first one in your environment variables.
I vagely remember that i had something similar. I think i ended up deleting all ssh clients and make sure windows build in openssh is the choosen one when connecting.
I have removed all other ssh clients (I believe): PuTTY, WinSCP, Wireshark …
Same thing, it asks me for the password when starting Karaf Console.
Here are my environment variables; moving “OpenSSH” to the Top does not make a difference
One more thing I noticed is that the Key in the .pub file and in the “known_hosts” file is NOT the same, see below screenshot from the .ssh directory on my Win 10 PC. Is that an issue ?
Is there a way to explicitly choose openssh when connecting from VSCode Powershell terminal window ?