[GH-ISSUE #179] how to auto start before login at Ubuntu 16.04 #142

Closed
opened 2026-05-05 05:22:38 -06:00 by gitea-mirror · 18 comments
Owner

Originally created by @Hokwang on GitHub (Nov 21, 2018).
Original GitHub issue: https://github.com/debauchee/barrier/issues/179

Operating Systems

Server: Windows 7

Client: Ubuntu 16.04

Barrier Version

barrierc --version

barrierc 2.2.0-Release

Steps to reproduce bug

In Ubuntu,
How to auto start before login ?

I think I can use systemd but that's not easy (I am beginner.)

I did like below

# vi /lib/systemd/system/barrier.service
[Unit]
Description=Barrier for sharing mouse and keyboard
After=network.target graphical-session.target

[Service]
ExecStart=/usr/bin/barrierc -f --debug INFO --name resisa-4 --enable-crypto [10.251.156.87]:24800
Restart=always
SyslogLevel=err

[Install]
WantedBy=multi-user.target

# systemctl daemon-reload
# systemctl enable barrier
# reboot

and then there's a problem.

# systemctl status barrier
\u25cf barrier.service - Barrier for sharing mouse and keyboard
   Loaded: loaded (/lib/systemd/system/barrier.service; enabled; vendor preset: enabled)
   Active: active (running) since \uc218 2018-11-21 20:43:28 KST; 23s ago
 Main PID: 1610 (barrierc)
    Tasks: 3
   Memory: 1.5M
      CPU: 9ms
   CGroup: /system.slice/barrier.service
           \u2514\u25001610 /usr/bin/barrierc -f --debug INFO --name resisa-4 --enable-crypto [10.251.156.87]:24800

11\uc6d4 21 20:43:28 resisa-4 systemd[1]: Started Barrier for sharing mouse and keyboard.
11\uc6d4 21 20:43:28 resisa-4 barrierc[1610]: No protocol specified
11\uc6d4 21 20:43:28 resisa-4 barrierc[1610]: [2018-11-21T20:43:28] WARNING: secondary screen unavailable: unable to open screen
Originally created by @Hokwang on GitHub (Nov 21, 2018). Original GitHub issue: https://github.com/debauchee/barrier/issues/179 ### Operating Systems ### Server: Windows 7 Client: Ubuntu 16.04 ### Barrier Version ### # barrierc --version barrierc 2.2.0-Release ### Steps to reproduce bug ### In Ubuntu, How to auto start before login ? I think I can use systemd but that's not easy (I am beginner.) I did like below ``` # vi /lib/systemd/system/barrier.service [Unit] Description=Barrier for sharing mouse and keyboard After=network.target graphical-session.target [Service] ExecStart=/usr/bin/barrierc -f --debug INFO --name resisa-4 --enable-crypto [10.251.156.87]:24800 Restart=always SyslogLevel=err [Install] WantedBy=multi-user.target # systemctl daemon-reload # systemctl enable barrier # reboot ``` and then there's a problem. ``` # systemctl status barrier \u25cf barrier.service - Barrier for sharing mouse and keyboard Loaded: loaded (/lib/systemd/system/barrier.service; enabled; vendor preset: enabled) Active: active (running) since \uc218 2018-11-21 20:43:28 KST; 23s ago Main PID: 1610 (barrierc) Tasks: 3 Memory: 1.5M CPU: 9ms CGroup: /system.slice/barrier.service \u2514\u25001610 /usr/bin/barrierc -f --debug INFO --name resisa-4 --enable-crypto [10.251.156.87]:24800 11\uc6d4 21 20:43:28 resisa-4 systemd[1]: Started Barrier for sharing mouse and keyboard. 11\uc6d4 21 20:43:28 resisa-4 barrierc[1610]: No protocol specified 11\uc6d4 21 20:43:28 resisa-4 barrierc[1610]: [2018-11-21T20:43:28] WARNING: secondary screen unavailable: unable to open screen ```
gitea-mirror 2026-05-05 05:22:39 -06:00
Author
Owner

@AdrianKoshka commented on GitHub (Nov 21, 2018):

That's a dangerous service file, as barrier is being ran as root. As how to run it before login, I can't think of a way at the moment. Also, user created unit files go in /etc/systemd/system/.

<!-- gh-comment-id:440833523 --> @AdrianKoshka commented on GitHub (Nov 21, 2018): That's a dangerous service file, as barrier is being ran as root. As how to run it before login, I can't think of a way at the moment. Also, user created unit files go in `/etc/systemd/system/`.
Author
Owner

@Hokwang commented on GitHub (Nov 22, 2018):

I find https://help.ubuntu.com/community/SynergyHowto#Autostart_Synergy_before_logging_in_.28LightDM.29
link for synergy.

Like this, I tried but failed.

Let's think about user has one windows PC and one ubuntu PC and one mouse and keyboard.
If reboot ubuntu, how can I login ubuntu ?
If autostart before login does not work, user should have to connect mouse and keyboard to ubuntu PC.

<!-- gh-comment-id:440935454 --> @Hokwang commented on GitHub (Nov 22, 2018): I find https://help.ubuntu.com/community/SynergyHowto#Autostart_Synergy_before_logging_in_.28LightDM.29 link for synergy. Like this, I tried but failed. Let's think about user has one windows PC and one ubuntu PC and one mouse and keyboard. If reboot ubuntu, how can I login ubuntu ? If autostart before login does not work, user should have to connect mouse and keyboard to ubuntu PC.
Author
Owner

@AdrianKoshka commented on GitHub (Nov 22, 2018):

I find help.ubuntu.com/community/SynergyHowto#Autostart_Synergy_before_logging_in_.28LightDM.29 link for synergy.

Beware, this would also run synergy/barrier as root.

Let's think about user has one windows PC and one ubuntu PC and one mouse and keyboard.
If reboot ubuntu, how can I login ubuntu ?
If autostart before login does not work, user should have to connect mouse and keyboard to ubuntu PC.

One thing that comes to mind is having the ubuntu machine auto-login (if you're comfortable with that).

<!-- gh-comment-id:441102598 --> @AdrianKoshka commented on GitHub (Nov 22, 2018): > I find help.ubuntu.com/community/SynergyHowto#Autostart_Synergy_before_logging_in_.28LightDM.29 link for synergy. Beware, this would also run synergy/barrier as root. > Let's think about user has one windows PC and one ubuntu PC and one mouse and keyboard. If reboot ubuntu, how can I login ubuntu ? If autostart before login does not work, user should have to connect mouse and keyboard to ubuntu PC. One thing that comes to mind is having the ubuntu machine auto-login (if you're comfortable with that).
Author
Owner

@marcelinomalmeidan commented on GitHub (Feb 1, 2019):

@Hokwang, I wonder if you have succeeded.
I am able to start barrierc on boot (the computer logs in automatically), and it runs in the background, but the mouse icon is invisible. The mouse icon only becomes visible once I physically plug/unplug the mouse on this computer. This defeats the whole purpose of "booting the computer and having mouse/keyboard without ever physically plugging them in"

I believe this is more of a Linux problem than "barrier" problem, but I wasn't able to find a solution to this...

<!-- gh-comment-id:459810817 --> @marcelinomalmeidan commented on GitHub (Feb 1, 2019): @Hokwang, I wonder if you have succeeded. I am able to start barrierc on boot (the computer logs in automatically), and it runs in the background, but the mouse icon is invisible. The mouse icon only becomes visible once I physically plug/unplug the mouse on this computer. This defeats the whole purpose of "booting the computer and having mouse/keyboard without ever physically plugging them in" I believe this is more of a Linux problem than "barrier" problem, but I wasn't able to find a solution to this...
Author
Owner

@carlgrosser commented on GitHub (Mar 6, 2019):

I'm wondering if this was figured out as well. I have been using login screen via VNC connection for now but would be nice to not have to load that every time I log out of my second machine (ubuntu).

<!-- gh-comment-id:470271866 --> @carlgrosser commented on GitHub (Mar 6, 2019): I'm wondering if this was figured out as well. I have been using login screen via VNC connection for now but would be nice to not have to load that every time I log out of my second machine (ubuntu).
Author
Owner

@evictor commented on GitHub (May 3, 2019):

@noisyshape is the "ideal world" scenario possible—that Barrier can start soon enough to allow for password entry on the Ubuntu machine that doesn't have KB/mouse plugged in? I can't have this machine log in automatically in an office environment for security/privacy reasons.

<!-- gh-comment-id:488886061 --> @evictor commented on GitHub (May 3, 2019): @noisyshape is the "ideal world" scenario possible—that Barrier can start soon enough to allow for password entry on the Ubuntu machine that doesn't have KB/mouse plugged in? I can't have this machine log in automatically in an office environment for security/privacy reasons.
Author
Owner

@hovissimo commented on GitHub (Jun 14, 2019):

@evictor Very important question: If barrier is running before you log in (so that you can log in), what user is barrier running under?

If autologin is considered unsafe, then running barrier as root is definitely unsafe. Perhaps you can make some kind of limited user just for barrier, but I'm not sure how that would work or if it's feasible.

<!-- gh-comment-id:502170108 --> @hovissimo commented on GitHub (Jun 14, 2019): @evictor Very important question: If barrier is running before you log in (so that you can log in), what user is barrier running under? If autologin is considered unsafe, then running barrier as root is definitely unsafe. Perhaps you can make some kind of limited user just for barrier, but I'm not sure how that would work or if it's feasible.
Author
Owner

@AdrianKoshka commented on GitHub (Jun 14, 2019):

If you're using a systemd unit file for the service, you might be able to use DyanmicUser=yes, which would generate a unprivileged user every time the service starts to run the service under.

<!-- gh-comment-id:502182984 --> @AdrianKoshka commented on GitHub (Jun 14, 2019): If you're using a systemd unit file for the service, you might be able to use [`DyanmicUser=yes`](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#DynamicUser=), which would generate a unprivileged user every time the service starts to run the service under.
Author
Owner

@marcelinomalmeidan commented on GitHub (Jun 14, 2019):

Personally, I have solved this issue by making ubuntu login without asking for password, then make barrier start automatically and then lock the screen using gnome-screensaver-command -l

<!-- gh-comment-id:502189482 --> @marcelinomalmeidan commented on GitHub (Jun 14, 2019): Personally, I have solved this issue by making ubuntu login without asking for password, then make barrier start automatically and then lock the screen using gnome-screensaver-command -l
Author
Owner

@marcelinomalmeidan commented on GitHub (Jun 14, 2019):

As for my comment above on the invisible mouse, I fixed it with gsettings set org-gnome.settings-daemon.plugins.cursor active false

<!-- gh-comment-id:502191336 --> @marcelinomalmeidan commented on GitHub (Jun 14, 2019): As for my comment above on the invisible mouse, I fixed it with ```gsettings set org-gnome.settings-daemon.plugins.cursor active false```
Author
Owner

@evictor commented on GitHub (Jun 17, 2019):

Thx all for the very good input re: login user.

Another somewhat related concern for always-on Barrier client—what is stopping a malicious party with access to the network from pretending to be the server and then gaining control of the client? For instance, I connect to the server via static hostname, but if the server is offline someone can just pose w/ that hostname and instantly get control of the client.

I don't see any built-in features to handle authentication but that would be excellent if a handshake of some sort could happen (esp. key-based auth) on connect. Or maybe just a warning + refusal to connect if the SSL fingerprint has changed. In that scenario it is reasonable to me to require direct keyboard/mouse on the remote machine to authorize the connection.

For reference we are using Barrier for an always-on big screen monitoring dash.

<!-- gh-comment-id:502836448 --> @evictor commented on GitHub (Jun 17, 2019): Thx all for the very good input re: login user. Another somewhat related concern for always-on Barrier client—what is stopping a malicious party with access to the network from pretending to be the server and then gaining control of the client? For instance, I connect to the server via static hostname, but if the server is offline someone can just pose w/ that hostname and instantly get control of the client. I don't see any built-in features to handle authentication but that would be excellent if a handshake of some sort could happen (esp. key-based auth) on connect. Or maybe just a warning + refusal to connect if the SSL fingerprint has changed. In that scenario it is reasonable to me to require direct keyboard/mouse on the remote machine to authorize the connection. For reference we are using Barrier for an always-on big screen monitoring dash.
Author
Owner

@marcelinomalmeidan commented on GitHub (Jun 17, 2019):

I do not have a lot of knowledge about any of this, but I know that there is a fingerprint detection that takes place for the client to recognize the server. I have to accept the fingerprint the first time I run the client on a new computer.

<!-- gh-comment-id:502837997 --> @marcelinomalmeidan commented on GitHub (Jun 17, 2019): I do not have a lot of knowledge about any of this, but I know that there is a fingerprint detection that takes place for the client to recognize the server. I have to accept the fingerprint the first time I run the client on a new computer.
Author
Owner

@noisyshape commented on GitHub (Jun 17, 2019):

Servers can be authenticated with a fingerprint. The GUI program is supposed to kill the client when there's an unapproved fingerprint. Unless I'm mistaken, the client itself doesn't handle fingerprints and if you're running the client by itself you may silently connect to an unauthenticated server.

<!-- gh-comment-id:502863352 --> @noisyshape commented on GitHub (Jun 17, 2019): Servers can be authenticated with a fingerprint. The GUI program is supposed to kill the client when there's an unapproved fingerprint. Unless I'm mistaken, the client itself doesn't handle fingerprints and if you're running the client by itself you may silently connect to an unauthenticated server.
Author
Owner

@yonderblue commented on GitHub (Jul 11, 2019):

Note this works for me on raspbian (assuming you want to control the Pi with another machine):

pi@raspberrypi:~ $ cat /etc/systemd/system/barrier.service 
[Unit]
Description=Barrier mouse/keyboard share
Requires=display-manager.service
After=display-manager.service
StartLimitIntervalSec=0

[Service]
Type=forking
ExecStart=/usr/bin/barrierc --no-restart --name raspberrypi 192.168.10.12
Restart=always
RestartSec=10
User=pi

[Install]
WantedBy=multi-user.target
<!-- gh-comment-id:510380412 --> @yonderblue commented on GitHub (Jul 11, 2019): Note this works for me on raspbian (assuming you want to control the Pi with another machine): ``` pi@raspberrypi:~ $ cat /etc/systemd/system/barrier.service [Unit] Description=Barrier mouse/keyboard share Requires=display-manager.service After=display-manager.service StartLimitIntervalSec=0 [Service] Type=forking ExecStart=/usr/bin/barrierc --no-restart --name raspberrypi 192.168.10.12 Restart=always RestartSec=10 User=pi [Install] WantedBy=multi-user.target ```
Author
Owner

@ghost commented on GitHub (Jun 17, 2020):

in case someone comes back here:
what worked for me was to follow what marcelinomalmeidan did:
set up auto-login in /etc/gdm3/custom.conf
and then gsettings set org.gnome.settings-daemon.plugins.cursor active false

<!-- gh-comment-id:645108086 --> @ghost commented on GitHub (Jun 17, 2020): in case someone comes back here: what worked for me was to follow what marcelinomalmeidan did: set up auto-login in /etc/gdm3/custom.conf and then gsettings set org.gnome.settings-daemon.plugins.cursor active false
Author
Owner

@Hokwang commented on GitHub (Jun 18, 2020):

I found out this,

$ sudo vi /etc/lightdm/lightdm.conf
 
[SeatDefaults]
autologin-user=
greeter-setup-script=/usr/bin/barrierc --debug INFO --name <Ubuntu PC hostname> <Windows PC IP>:24800

and reboot.

So I close this.

<!-- gh-comment-id:645756638 --> @Hokwang commented on GitHub (Jun 18, 2020): I found out this, ``` $ sudo vi /etc/lightdm/lightdm.conf [SeatDefaults] autologin-user= greeter-setup-script=/usr/bin/barrierc --debug INFO --name <Ubuntu PC hostname> <Windows PC IP>:24800 ``` and reboot. So I close this.
Author
Owner

@SteveClement commented on GitHub (Oct 5, 2020):

lightdm has changed config file format, newer versions need:

[Seat:*]
.
.
.

But more things seem to have changed and somehow my setup does not reliably work anymore... (Like a 1 minute delay to connect back to the server)

This is certainly on my network though.

<!-- gh-comment-id:703427325 --> @SteveClement commented on GitHub (Oct 5, 2020): lightdm has changed config file format, newer versions need: ``` [Seat:*] . . . ```` But more things seem to have changed and somehow my setup does not reliably work anymore... (Like a 1 minute delay to connect back to the server) This is certainly on my network though.
Author
Owner

@twnaing commented on GitHub (Nov 21, 2021):

ArchLinux aur has slim-synergy package. I think someone could easily replace synergy with barrier easily.

<!-- gh-comment-id:974799255 --> @twnaing commented on GitHub (Nov 21, 2021): ArchLinux aur has [slim-synergy](https://aur.archlinux.org/packages/slim-synergy/) package. I think someone could easily replace synergy with barrier easily.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/barrier#142
No description provided.