maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [M5] [Announce] OpenSSH status widget (https://talk.maemo.org/showthread.php?t=95429)

rasmarc 2015-04-28 22:11

[Announce] OpenSSH status widget
 
4 Attachment(s)
This OpenSSH status widget provides a GUI to control the OpenSSH daemon as well as wifi power management from the status menu in many useful ways:
  • puts a configurable button in the status menu to control the OpenSSH server and wifi power management
  • displays server status
  • offers connections overview
  • displays a customizable icon in the status area
  • displays wifi pm settings
  • detects conflicting "respawn" system setting and can disable it

    Widget options:
    • Enable tracking of server status
      When not enabled, just switch the server daemon on/off and call up the number of connections manually by long pressing the button.
    • Stop tracking when server is off
      Recommended for minimizing power consumption
    • Show status 'connected' in status area
      When one or more server connections are active the status area icon will show an additional symbol or alternatively change its color
    • Show dialog on long tap
      Shows a configurable dialog instead of disconnecting instantly
    • Show wifi power management button
    OpenSSH options:
    • Run server at system startup
      Switch autostart on/off
    • Stop server when not connected for xx minutes
      Stop server automatically when not needed
    Wifi pm options:
    • Keep wifi power management off when connected
      Avoid input lags caused by wifi power management. This feature handles server connections and client connections.
      Because keeping off power management drains the battery quite a lot there's an experimental toggle mode which allows to toggle power management every few seconds in order to find a balance between power consumption and appearing input lags.

The attached image shows the button when
  • server is on and ready
  • server is on with 3 active connections
  • server is waiting for 1 connection to close - wifi pm feature is disabled
  • server is off - wifi pm is kept off when connected
  • server is on with tracking disabled - wifi pm is in toggle mode when connected

A short tap on the main button starts the server and stops it without closing active connections.
A long tap on the main button either shows a configurable dialog or disconnects and stops the server instantly. When tracking is disabled the number of connections can be called up additionally.

A short tap on the wifi pm button keeps wifi pm off for 30 seconds. This solves login problems caused by wifi pm.
A long tap on the wifi pm button opens wifi pm settings.

Settings can be accessed from the dialog window or by opening "OSW Options" in the application menu, category desktop.

OpenSSH Status Widget can be found in Extras-testing and Extras-devel.
Download of the latest deb file is available from the package website.

nokiabot 2015-04-29 02:12

Re: [Announce] OpenSSH status widget
 
nice nice i had been playing with ssh lately this will help .
btw add announce to thread title or it looks like help thread

scy 2015-04-29 04:48

Re: [Announce] OpenSSH status widget
 
Thanks for this - I was looking for such a tool for some time now.

Here ist the first feedback: When I click on the widget to stop the server, it notifies me "Could NOT stop OpenSSH server!".

However, the widget then shows "off".

I tried to manually kill sshd. The sshd process gets restarted instantly.

How to solve this? And what also interests me: what is the command line instruction to count all ssh connections?

nokiabot 2015-04-29 05:43

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by scy (Post 1468807)
Thanks for this - I was looking for such a tool for some time now.

Here ist the first feedback: When I click on the widget to stop the server, it notifies me "Could NOT stop OpenSSH server!".

However, the widget then shows "off".

I tried to manually kill sshd. The sshd process gets restarted instantly.

How to solve this? And what also interests me: what is the command line instruction to count all ssh connections?

exact same problem here

rasmarc 2015-04-30 08:08

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by scy (Post 1468807)
When I click on the widget to stop the server, it notifies me "Could NOT stop OpenSSH server!".

However, the widget then shows "off".

I tried to manually kill sshd. The sshd process gets restarted instantly.

How to solve this? And what also interests me: what is the command line instruction to count all ssh connections?

Thanks for the feedback. Please have a look at /etc/event.d/sshd and check if two lines are commented out:
Code:

#start on stopped rcS

#respawn

.
Quote:

Originally Posted by scy (Post 1468807)
And what also interests me: what is the command line instruction to count all ssh connections?

I used
Code:

ps aux | grep sshd: | grep -c @

I just uploaded v1.0-2 with corrected status detection when an error occurs.

scy 2015-04-30 14:06

Re: [Announce] OpenSSH status widget
 
Thanks for the feedback and notes. I commented out the 2 lines and installed the new version. Now it works!

scy 2015-04-30 14:34

Re: [Announce] OpenSSH status widget
 
One more feedback in regards to this handy little tool:

If the sshd gets started from the command line, the widget show as status "off". It then also does not show the number of ssh connections.

rasmarc 2015-04-30 20:04

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by scy (Post 1468993)
If the sshd gets started from the command line, the widget show as status "off". It then also does not show the number of ssh connections.

This was made intentionally. When the server is completely off i saw no real benefit in tracking its status and so having the widget being active all the time. But in fact i can't estimate if this would have a noticeable effect on cpu or battery.

At the moment when you start the server from command line for some reason you can make the widget start tracking just by pressing its button. The widget will recognize and display the server's real status and in addition give a respective note.

I think about adding a configuration window with an autostart option and an optional confirmation dialog when closing active connections. So maybe an option to keep tracking when the server is off might also be added.

rasmarc 2015-05-07 13:46

Re: [Announce] OpenSSH status widget
 
A new version 1.1-2 is uploaded.

Main change is a new configuration dialog, see attached image in post #1.

The default behaviour is now to keep tracking server status even when the server is off. This can be turned off if there's worry about battery drain.

The configuration dialog has no "save" button, changes are saved instantly. But for the widget options to be applied in the current session the status menu has to be restarted. This can be done from the main menu.

I also added detection of a conflicting server configuration in /etc/event.d/sshd. So i hope the widget is now ready to use in any case.:)

Changes in v1.1-0:
*added optional confirmation dialog when disconnecting
*changed default configuration to keep tracking when off
*added configuration window with 3 options:
autostart, confirm when disconnecting, stop tracking when off
*added system check for conflicting "respawn" option
with optional correction

Changes in v1.1-1:
*typo bugfix

Changes in v1.1-2:
*small change: make sure /etc/event.d/sshd has correct 'start on' entry

ThomasAH 2015-05-07 14:29

Re: [Announce] OpenSSH status widget
 
Thanks for this rasmarc! :) At the moment I'm using the 'SSH Status and Switcher' status-applet, but it doesn't show if there are any current connections, so I'd like to check yours out.

Is there any chance you could place the deb here in the first post? I don't have extras-devel enabled.

rasmarc 2015-05-07 14:49

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by ThomasAH (Post 1469623)
Is there any change you could place the deb here in the first post? I don't have extras-devel enabled.

You can download the latest deb from the package website. I added a link in the first post. Thanx for the hint.

handaxe 2015-05-07 16:11

Re: [Announce] OpenSSH status widget
 
I uninstalled SSH Status and Switcher thinking it might be the root of my issue, but this persists:

Code:

~ $ openssh-status-config.py
Traceback (most recent call last):
  File "/usr/bin/openssh-status-config.py", line 172, in <module>
    Main()
  File "/usr/bin/openssh-status-config.py", line 37, in __init__
    confirmDisconnect = self.parser.getboolean('options', 'confirmDisconnect')
  File "/usr/lib/python2.5/ConfigParser.py", line 330, in getboolean
    v = self.get(section, option)
  File "/usr/lib/python2.5/ConfigParser.py", line 511, in get
    raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'options'


rasmarc 2015-05-07 17:01

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by handaxe (Post 1469629)
I uninstalled SSH Status and Switcher thinking it might be the root of my issue, but this persists:

There's a typo in the code that appeared when i changed a variable name, sorry. Now the created config file remains empty - which i didn't recognize because it was already created on my device. If you don't want to wait for the fix you may open

/home/user/.openssh-status-widget

and copy these lines:
Code:

[options]
confirmDisconnect = True
stopTracking = False
skipSystemCheck = False

Doing this, the configuration dialog shouldn't crash anymore.

rasmarc 2015-05-07 19:16

Re: [Announce] OpenSSH status widget
 
I just uploaded v1.1-3 to extras-devel.

Changes:
*bugfix: empty config file made app crash:eek:


All cases of a non-working config file are tested, but if there's still a fault, please let me know.

ThomasAH 2015-05-07 21:21

Re: [Announce] OpenSSH status widget
 
Nice! Well, due to extreme slowness of http://maemo.org/packages/ (is it that slow for everybody or just me?) I wasn't able to download any of the packages, so I guess I'll just wait 'til it hits extras-testing :D

handaxe 2015-05-07 21:34

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by rasmarc (Post 1469642)
I just uploaded v1.1-3 to extras-devel.

...
All cases of a non-working config file are tested, but if there's still a fault, please let me know.

Thanks for this. I might have a permissions issue or an odd config entry somewhere or other, as the widget cannot start the ssh server.
Code:

/etc/init.d/ssh start
does just fine. Will look into this tomorrow.

rasmarc 2015-05-07 21:48

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by ThomasAH (Post 1469655)
Nice! Well, due to extreme slowness of http://maemo.org/packages/ (is it that slow for everybody or just me?) I wasn't able to download any of the packages, so I guess I'll just wait 'til it hits extras-testing :D

Downloading the deb file (32KB) from here does not work for you?

http://maemo.org/packages/package_in...-widget/1.1-3/

rasmarc 2015-05-07 22:10

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by handaxe (Post 1469657)
Thanks for this. I might have a permissions issue or an odd config entry somewhere or other, as the widget cannot start the ssh server.
Code:

/etc/init.d/ssh start
does just fine. Will look into this tomorrow.

The widget uses the same command ("sudo /etc/init.d/ssh start"). What about stopping the server by short pressing (that's "sudo /etc/init.d/ssh stop") and long pressing ("sudo killall sshd") the button? Does that work for you?

ThomasAH 2015-05-07 22:34

Re: [Announce] OpenSSH status widget
 
1 Attachment(s)
Quote:

Originally Posted by rasmarc (Post 1469658)
Downloading the deb file (32KB) from here does not work for you?

http://maemo.org/packages/package_in...-widget/1.1-3/

Indeed, it does not. Connection times out for me.

Edit: Scratch that, the package website just takes really long to load, and I managed to download the package after waiting for 5-10 minutes... So I downloaded and installed openssh-status-widget_1.1-3_armel.deb, however, the status-applet does not appear to display any image (see attachment (yeah, my battery is really low :D ), it's the blank entry at the bottom-right). When pressed, it does not respond at all. Any idea what might cause this?

rasmarc 2015-05-07 23:22

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by ThomasAH (Post 1469664)
it's the blank entry at the bottom-right). When pressed, it does not respond at all. Any idea what might cause this?

Does
Code:

/usr/lib/hildon-desktop/openssh-status-widget.py
give you any output on the terminal?

ThomasAH 2015-05-07 23:35

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by rasmarc (Post 1469667)
Does
Code:

/usr/lib/hildon-desktop/openssh-status-widget.py
give you any output on the terminal?

It does!

Code:

BusyBox v1.23.1 (Debian 1.23.1power2) built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ $ sudo gainroot
Root shell enabled

BusyBox v1.23.1 (Debian 1.23.1power2) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/home/user # /usr/lib/hildon-desktop/openssh-status-widget.py
 
process 1956: arguments to dbus_connection_get_data() were incorrect, assertion "connection != NULL" failed in file dbus-connection.c line 5757.
This is normally a bug in some application using the D-Bus library.
process 1956: arguments to dbus_connection_set_data() were incorrect, assertion "connection != NULL" failed in file dbus-connection.c line 5721.
This is normally a bug in some application using the D-Bus library.
Aborted

I am running CSSU-testing, not thumb, might that be a problem?

rasmarc 2015-05-08 00:27

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by ThomasAH (Post 1469668)
It does!

[I am running CSSU-testing, not thumb, might that be a problem?

I cannot say much about that. You can try in a terminal (one line):

Code:

dbus-send --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:qwertz uint32:0 string:
Does this display a popup message?

If so (and if not also:D) try this one:

Code:

run-standalone.sh dbus-send --print-reply --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:qwertz uint32:0 string:dummy

handaxe 2015-05-08 08:26

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by rasmarc (Post 1469660)
The widget uses the same command ("sudo /etc/init.d/ssh start"). What about stopping the server by short pressing (that's "sudo /etc/init.d/ssh stop") and long pressing ("sudo killall sshd") the button? Does that work for you?

Ok, the issue is "sudo". My setup asks for a password.

ThomasAH 2015-05-08 09:19

Re: [Announce] OpenSSH status widget
 
I tried, and the outcome is interesting :)

As root, the first command fails and the second succeeds. However, when I tried them as a normal user (not root), both of them worked!

Here is the output:
Code:

BusyBox v1.23.1 (Debian 1.23.1power2) built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ $ sudo gainroot
Root shell enabled


BusyBox v1.23.1 (Debian 1.23.1power2) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/home/user # dbus-send --dest=org.freedesktop.Notifications /
org/freedesktop/Notifications org.freedesktop.Notifications.S
ystemNoteDialog string:qwertz uint32:0 string:
Failed to open connection to "session" message bus: (null)

/home/user # run-standalone.sh dbus-send --print-reply --typ
e=method_call --dest=org.freedesktop.Notifications /org/free
desktop/Notifications org.freedesktop.Notifications.SystemNo
teDialog string:qwertz uint32:0 string:dummy
method return sender=:1.31 -> dest=:1.132 reply_serial=2
  uint32 12

/home/user # exit

~ $ dbus-send --dest=org.freedesktop.Notifications /org/free
desktop/Notifications org.freedesktop.Notifications.SystemNo
teDialog string:qwertz uint32:0 string:

~ $ run-standalone.sh dbus-send --print-reply --type=method_
call --dest=org.freedesktop.Notifications /org/freedesktop/N
otifications org.freedesktop.Notifications.SystemNoteDialog
string:qwertz uint32:0 string:dummy
method return sender=:1.31 -> dest=:1.134 reply_serial=2
  uint32 14

Hope this helps!

rasmarc 2015-05-08 10:03

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by ThomasAH (Post 1469686)
Hope this helps!

I've been on the wrong track. Please try again as user, not root:
Code:

/usr/lib/hildon-desktop/openssh-status-widget.py
Any output this time?

ThomasAH 2015-05-08 10:18

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by rasmarc (Post 1469688)
I've been on the wrong track. Please try again as user, not root:
Code:

/usr/lib/hildon-desktop/openssh-status-widget.py
Any output this time?

No output at all, not even a error message.

As user:
Code:

BusyBox v1.23.1 (Debian 1.23.1power2) built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ $ /usr/lib/hildon-desktop/openssh-status-widget.py
~ $


rasmarc 2015-05-08 11:47

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by ThomasAH (Post 1469689)
No output at all, not even a error message.

Have you started the configuration dialog once? It's in the application menu, called "OSW Options". Then please restart the status menu from the the configiguration dialog's main menu.

Still an empty button?

rasmarc 2015-05-08 11:51

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by handaxe (Post 1469684)
Ok, the issue is "sudo". My setup asks for a password.

Which packages have you installed? rootsh and Sudser?

handaxe 2015-05-08 12:12

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by rasmarc (Post 1469694)
Which packages have you installed? rootsh and Sudser?

rootsh....

Difficult to remember, but I probably set a root password (?)

ThomasAH 2015-05-08 12:15

Re: [Announce] OpenSSH status widget
 
3 Attachment(s)
Quote:

Originally Posted by rasmarc (Post 1469693)
Have you started the configuration dialog once? It's in the application menu, called "OSW Options". Then please restart the status menu from the the configiguration dialog's main menu.

That was it! :) I hadn't run the OSW Options configuration yet (I didn't know it existed). After configuring it I just rebooted the phone, now it's working! :D I tested it and it seems to work as expected (See attachments)

Perhaps you chould add a instruction to the first post that you should run the OSW Options configuration once before using it? I couldn't find anywhere that this was necessary.

Thanks a lot for all your help and patience, and for the status-widget of course! :)

PS.: I love the blowfish icon

rasmarc 2015-05-08 12:29

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by handaxe (Post 1469696)
rootsh....

Difficult to remember, but I probably set a root password (?)

I've set a root password as well, but sudo won't ask for it, so that's probalbly not the issue. You could have a look at the list of installed packages in the Application manager->Uninstall, and check if you have Sudser installed.

If so, an exclusion can be added not to ask for a password for the relevant commands (i never did this before, will have to try). And if that works an option in the configuration dialog would be useful.

Edit:
I was wrong here - the opposite is true. Sudser let's you execute sudo without a password. I'll have a look on how to execute the relevant commands without a password.

rasmarc 2015-05-08 12:54

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by ThomasAH (Post 1469697)
That was it! :) I hadn't run the OSW Options configuration yet (I didn't know it existed). After configuring it I just rebooted the phone, now it's working! :D I tested it and it seems to work as expected (See attachments)

Perhaps you chould add a instruction to the first post that you should run the OSW Options configuration once before using it? I couldn't find anywhere that this was necessary.

It should not be necessary to run OSW Options first. A typo in conjunction with your system settings was probably the reason for this again. I will wait uploading the fix and see if handaxe's issue gets solved quickly.

Nice that it works now. :cool:

rasmarc 2015-05-08 20:21

Re: [Announce] OpenSSH status widget
 
v1.2-1 is uploaded!

Main change: the sudo password issue is solved. I put all sudo commands in an extra shell script and added an entry in the sudoers.d directory.

@handaxe: This could work for you. I uninstalled Sudser, which made sudo ask me for a password and the widget not switch anymore, just as you reported. This new version works properly again on my device.

Changes:
*bugfix: typo led to empty button on fresh install
*enabled sudo commands without password

handaxe 2015-05-11 16:00

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by rasmarc (Post 1469724)
@handaxe: This could work for you. I uninstalled Sudser, which made sudo ask me for a password and the widget not switch anymore, just as you reported. This new version works properly again on my device.

Fook, it still will not start for me. Will take a look. But thanks, this is very nice.

Ok, if I run

Code:

/usr/sbin/openssh-status.sg start_sshd
it gives an operation not permitted error.

rasmarc 2015-05-11 16:21

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by handaxe (Post 1469998)
Fook, it still will not start for me. Will take a look. But thanks, this is very nice.

Well, that's interesting. :)

I guess you mean the button appears in the status menu but it won't start/stop the server. Maybe your device doesn't update the sudoer's list.

You can try as root:
Code:

/usr/sbin/update-sudoers
Another question:
1. Start the configuration dialog
2. Switch "Run server at system startup"
3. Switch one of the widget's options
3. Close and re-open the configuration dialog

Did it save any configuration?

handaxe 2015-05-11 16:37

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by rasmarc (Post 1470000)

Another question:
1. Start the configuration dialog
2. Switch "Run server at system startup"

Ha, thanks for the reminder - I forgot to mention previously that it did not save "Run server at system startup" option but did the others.

Now, having set it, it sticks, and then the widget works as advertised. Brilliant & thanks.

handaxe 2015-05-11 21:49

Re: [Announce] OpenSSH status widget
 
Strange, but after some time, the app indicator "forgets" that the server is enabled. Pressing the drop-drown generates an "already running, updating screen" (or words to that effect) message and the indicator reappears.

Is this "sleep" related?

rasmarc 2015-05-12 09:04

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by handaxe (Post 1470064)
Strange, but after some time, the app indicator "forgets" that the server is enabled. Pressing the drop-drown generates an "already running, updating screen" (or words to that effect) message and the indicator reappears.

Is this "sleep" related?

This needs a fix/workaround. It happens that the server status is recognized as off even when it should be on. The command for checking is
Code:

ps aux | grep -c usr/sbin/sshd
which i think can be assumed to be reliable.

Anyway, when "Stop tracking status when off" is enabled (you do have it enabled?) the widget immediately stops tracking as soon as status OFF is recognized. To handle those occasional short intervals correctly, when the sshd daemon seems non-listed in the process list, a time-out needs to be added before tracking stops.

ThomasAH 2015-05-12 09:26

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by rasmarc (Post 1470104)
Anyway, when "Stop tracking status when off" is enabled (you do have it enabled?) the widget immediately stops tracking as soon as status OFF is recognized. To handle those occasional short intervals correctly, when the sshd daemon seems non-listed in the process list, a time-out needs to be added before tracking stops.

I have an oddity that may be a related to what you describe above:
Even when the server is turned off, every once in a while the 'SSH' icon appears in the top tray-icon area (right of the clock) very briefly. It usually happens when I (dis)connect from a internet connection, or update my repositories. It even happens when "Stop tracking status when off" is enabled.

Do you have any idea why this might happen?

rasmarc 2015-05-12 14:46

Re: [Announce] OpenSSH status widget
 
Quote:

Originally Posted by ThomasAH (Post 1470109)
Every once in a while the 'SSH' icon appears in the top tray-icon area (right of the clock) very briefly. It usually happens when I (dis)connect from a internet connection, or update my repositories. It even happens when "Stop tracking status when off" is enabled.

Do you have any idea why this might happen?

I have no explanation for this so far. This is not triggered by the widget itself directly. Maybe the used python command for deleting the icon is somehow incomplete (?). It needs more investigation. :rolleyes:

The timeout for switching the display to off is now added. For the moment I used the shortest time possible (just one more checking, that is 2 seconds) not to delay updating the display to OFF too much. This affects only one situation, when the server is waiting for 1 connection to close (and when the server is stopped externally of course).

v1.2-2 is uploaded.

Changes:
*added timeout to avoid mistaken status off
*cosmetic change: message "display updated"


All times are GMT. The time now is 10:29.

vBulletin® Version 3.8.8