How to type into the lightdm login screen from the command line?

Clash Royale CLAN TAG#URR8PPP up vote
3
down vote
favorite
I have a computer with large hard drives configured with encrypted home. It so happens, that the same computer also works my family's main kodi media center. Each time my kids want to see a movie, I have to turn it on, and then physically connect a keyboard to it, and type in the password.
I would love to be able to do that remotely.
Of course I also have a root access to the computer.
I am not willing to create another username with automatic login, because most of the media files are encrypted and I want them to stay this way.
The normal combination of export DISPLAY=0: and source discover_session_bus_addres.sh and xdotool type my_secret_password that works for typing into the lock screen doesn't work on the lightm.
command-line login lightdm
add a comment |Â
up vote
3
down vote
favorite
I have a computer with large hard drives configured with encrypted home. It so happens, that the same computer also works my family's main kodi media center. Each time my kids want to see a movie, I have to turn it on, and then physically connect a keyboard to it, and type in the password.
I would love to be able to do that remotely.
Of course I also have a root access to the computer.
I am not willing to create another username with automatic login, because most of the media files are encrypted and I want them to stay this way.
The normal combination of export DISPLAY=0: and source discover_session_bus_addres.sh and xdotool type my_secret_password that works for typing into the lock screen doesn't work on the lightm.
command-line login lightdm
Which user did you run the commands as? LightDM's X session is probably run under thelightdmuser
â muru
Mar 29 at 6:19
@muru On Ubuntu 16.04 it is root.
â Adam Ryczkowski
Mar 29 at 7:02
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a computer with large hard drives configured with encrypted home. It so happens, that the same computer also works my family's main kodi media center. Each time my kids want to see a movie, I have to turn it on, and then physically connect a keyboard to it, and type in the password.
I would love to be able to do that remotely.
Of course I also have a root access to the computer.
I am not willing to create another username with automatic login, because most of the media files are encrypted and I want them to stay this way.
The normal combination of export DISPLAY=0: and source discover_session_bus_addres.sh and xdotool type my_secret_password that works for typing into the lock screen doesn't work on the lightm.
command-line login lightdm
I have a computer with large hard drives configured with encrypted home. It so happens, that the same computer also works my family's main kodi media center. Each time my kids want to see a movie, I have to turn it on, and then physically connect a keyboard to it, and type in the password.
I would love to be able to do that remotely.
Of course I also have a root access to the computer.
I am not willing to create another username with automatic login, because most of the media files are encrypted and I want them to stay this way.
The normal combination of export DISPLAY=0: and source discover_session_bus_addres.sh and xdotool type my_secret_password that works for typing into the lock screen doesn't work on the lightm.
command-line login lightdm
command-line login lightdm
asked Mar 29 at 5:41
Adam Ryczkowski
2,31252150
2,31252150
Which user did you run the commands as? LightDM's X session is probably run under thelightdmuser
â muru
Mar 29 at 6:19
@muru On Ubuntu 16.04 it is root.
â Adam Ryczkowski
Mar 29 at 7:02
add a comment |Â
Which user did you run the commands as? LightDM's X session is probably run under thelightdmuser
â muru
Mar 29 at 6:19
@muru On Ubuntu 16.04 it is root.
â Adam Ryczkowski
Mar 29 at 7:02
Which user did you run the commands as? LightDM's X session is probably run under the
lightdm userâ muru
Mar 29 at 6:19
Which user did you run the commands as? LightDM's X session is probably run under the
lightdm userâ muru
Mar 29 at 6:19
@muru On Ubuntu 16.04 it is root.
â Adam Ryczkowski
Mar 29 at 7:02
@muru On Ubuntu 16.04 it is root.
â Adam Ryczkowski
Mar 29 at 7:02
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
4
down vote
accepted
Here is an answer that works under Ubuntu 16.04 with lightdm:
- Make yourself
rootto get access to the lightdm's.Xauthority, which is located under/var/lib/lightdm/.Xauthority. Either copy it somewhere where it will be readable by you and drop your root permissions, or simply remain root. - set
XAUTHORITYto point to that file (e.g.export XAUTHORITY=/var/lib/lightdm/.Xauthority) - set
DISPLAYto the active display (export DISPLAY=:0) xdotoolshould work now. Tryxdotool type "My super secret password"
xdotool key Return
add a comment |Â
up vote
1
down vote
Here is the workaround that I'm using. It is ugly and rude, but this approach shall work also within Wayland and GDM (Ubuntu 17.10) if the auto login option works at all.
#!/bin/bash
# NAME: lightdm-auto-login
main()
# If the file '/etc/lightdm/lightdm.conf' exists create a backup copy
[[ -f /etc/lightdm/lightdm.conf ]] && mv /etc/lightdm/lightdm.conf,.bak
# Create autologin configuration for the current $USER = $1
echo -e "[Seat:*]nautologin-user=$1" > /etc/lightdm/lightdm.conf
# Restart 'lightdm' while autologin option is enabled
systemctl restart lightdm.service
# Wait for a moment to complete the login process and remove the conf file
sleep 30 && rm /etc/lightdm/lightdm.conf
# Restore the backup if exists
[[ -f /etc/lightdm/lightdm.conf.bak ]] && mv /etc/lightdm/lightdm.conf.bak,
# Execute the 'main()' function with root privileges in the background 'sudo -b'
# Pass the curent $USER as arg (https://unix.stackexchange.com/a/269080/201297)
sudo -b bash -c "$(declare -f main); main $USER"
The script should be executed as regular user (that belongs to the sudoers group).
The script will create a backup copy of the file
/etc/lightdm/lightdm.conf. Then it will generate a new configuration file with auto login option, enabled for the current user. At this point thelightdmwill be restarted and the user will be login by the auto login option. Finally the custom configuration will be removed and the original state of the configuration file will be restored.If GDM in use: the service to be restarted is
gdm3.serviceand the configuration file that should be changed is/etc/gdm3/custom.conf.
add a comment |Â
up vote
0
down vote
This works fine for me (from ssh, with lightdm):
$ XAUTHORITY=/var/lib/lightdm/.Xauthority DISPLAY=:0.0 sudo sh -c 'xdotool type "My Password" && xdotool key Return'
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Here is an answer that works under Ubuntu 16.04 with lightdm:
- Make yourself
rootto get access to the lightdm's.Xauthority, which is located under/var/lib/lightdm/.Xauthority. Either copy it somewhere where it will be readable by you and drop your root permissions, or simply remain root. - set
XAUTHORITYto point to that file (e.g.export XAUTHORITY=/var/lib/lightdm/.Xauthority) - set
DISPLAYto the active display (export DISPLAY=:0) xdotoolshould work now. Tryxdotool type "My super secret password"
xdotool key Return
add a comment |Â
up vote
4
down vote
accepted
Here is an answer that works under Ubuntu 16.04 with lightdm:
- Make yourself
rootto get access to the lightdm's.Xauthority, which is located under/var/lib/lightdm/.Xauthority. Either copy it somewhere where it will be readable by you and drop your root permissions, or simply remain root. - set
XAUTHORITYto point to that file (e.g.export XAUTHORITY=/var/lib/lightdm/.Xauthority) - set
DISPLAYto the active display (export DISPLAY=:0) xdotoolshould work now. Tryxdotool type "My super secret password"
xdotool key Return
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Here is an answer that works under Ubuntu 16.04 with lightdm:
- Make yourself
rootto get access to the lightdm's.Xauthority, which is located under/var/lib/lightdm/.Xauthority. Either copy it somewhere where it will be readable by you and drop your root permissions, or simply remain root. - set
XAUTHORITYto point to that file (e.g.export XAUTHORITY=/var/lib/lightdm/.Xauthority) - set
DISPLAYto the active display (export DISPLAY=:0) xdotoolshould work now. Tryxdotool type "My super secret password"
xdotool key Return
Here is an answer that works under Ubuntu 16.04 with lightdm:
- Make yourself
rootto get access to the lightdm's.Xauthority, which is located under/var/lib/lightdm/.Xauthority. Either copy it somewhere where it will be readable by you and drop your root permissions, or simply remain root. - set
XAUTHORITYto point to that file (e.g.export XAUTHORITY=/var/lib/lightdm/.Xauthority) - set
DISPLAYto the active display (export DISPLAY=:0) xdotoolshould work now. Tryxdotool type "My super secret password"
xdotool key Return
edited Apr 9 at 10:08
terdonâ¦
62k12127205
62k12127205
answered Mar 29 at 7:08
Adam Ryczkowski
2,31252150
2,31252150
add a comment |Â
add a comment |Â
up vote
1
down vote
Here is the workaround that I'm using. It is ugly and rude, but this approach shall work also within Wayland and GDM (Ubuntu 17.10) if the auto login option works at all.
#!/bin/bash
# NAME: lightdm-auto-login
main()
# If the file '/etc/lightdm/lightdm.conf' exists create a backup copy
[[ -f /etc/lightdm/lightdm.conf ]] && mv /etc/lightdm/lightdm.conf,.bak
# Create autologin configuration for the current $USER = $1
echo -e "[Seat:*]nautologin-user=$1" > /etc/lightdm/lightdm.conf
# Restart 'lightdm' while autologin option is enabled
systemctl restart lightdm.service
# Wait for a moment to complete the login process and remove the conf file
sleep 30 && rm /etc/lightdm/lightdm.conf
# Restore the backup if exists
[[ -f /etc/lightdm/lightdm.conf.bak ]] && mv /etc/lightdm/lightdm.conf.bak,
# Execute the 'main()' function with root privileges in the background 'sudo -b'
# Pass the curent $USER as arg (https://unix.stackexchange.com/a/269080/201297)
sudo -b bash -c "$(declare -f main); main $USER"
The script should be executed as regular user (that belongs to the sudoers group).
The script will create a backup copy of the file
/etc/lightdm/lightdm.conf. Then it will generate a new configuration file with auto login option, enabled for the current user. At this point thelightdmwill be restarted and the user will be login by the auto login option. Finally the custom configuration will be removed and the original state of the configuration file will be restored.If GDM in use: the service to be restarted is
gdm3.serviceand the configuration file that should be changed is/etc/gdm3/custom.conf.
add a comment |Â
up vote
1
down vote
Here is the workaround that I'm using. It is ugly and rude, but this approach shall work also within Wayland and GDM (Ubuntu 17.10) if the auto login option works at all.
#!/bin/bash
# NAME: lightdm-auto-login
main()
# If the file '/etc/lightdm/lightdm.conf' exists create a backup copy
[[ -f /etc/lightdm/lightdm.conf ]] && mv /etc/lightdm/lightdm.conf,.bak
# Create autologin configuration for the current $USER = $1
echo -e "[Seat:*]nautologin-user=$1" > /etc/lightdm/lightdm.conf
# Restart 'lightdm' while autologin option is enabled
systemctl restart lightdm.service
# Wait for a moment to complete the login process and remove the conf file
sleep 30 && rm /etc/lightdm/lightdm.conf
# Restore the backup if exists
[[ -f /etc/lightdm/lightdm.conf.bak ]] && mv /etc/lightdm/lightdm.conf.bak,
# Execute the 'main()' function with root privileges in the background 'sudo -b'
# Pass the curent $USER as arg (https://unix.stackexchange.com/a/269080/201297)
sudo -b bash -c "$(declare -f main); main $USER"
The script should be executed as regular user (that belongs to the sudoers group).
The script will create a backup copy of the file
/etc/lightdm/lightdm.conf. Then it will generate a new configuration file with auto login option, enabled for the current user. At this point thelightdmwill be restarted and the user will be login by the auto login option. Finally the custom configuration will be removed and the original state of the configuration file will be restored.If GDM in use: the service to be restarted is
gdm3.serviceand the configuration file that should be changed is/etc/gdm3/custom.conf.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Here is the workaround that I'm using. It is ugly and rude, but this approach shall work also within Wayland and GDM (Ubuntu 17.10) if the auto login option works at all.
#!/bin/bash
# NAME: lightdm-auto-login
main()
# If the file '/etc/lightdm/lightdm.conf' exists create a backup copy
[[ -f /etc/lightdm/lightdm.conf ]] && mv /etc/lightdm/lightdm.conf,.bak
# Create autologin configuration for the current $USER = $1
echo -e "[Seat:*]nautologin-user=$1" > /etc/lightdm/lightdm.conf
# Restart 'lightdm' while autologin option is enabled
systemctl restart lightdm.service
# Wait for a moment to complete the login process and remove the conf file
sleep 30 && rm /etc/lightdm/lightdm.conf
# Restore the backup if exists
[[ -f /etc/lightdm/lightdm.conf.bak ]] && mv /etc/lightdm/lightdm.conf.bak,
# Execute the 'main()' function with root privileges in the background 'sudo -b'
# Pass the curent $USER as arg (https://unix.stackexchange.com/a/269080/201297)
sudo -b bash -c "$(declare -f main); main $USER"
The script should be executed as regular user (that belongs to the sudoers group).
The script will create a backup copy of the file
/etc/lightdm/lightdm.conf. Then it will generate a new configuration file with auto login option, enabled for the current user. At this point thelightdmwill be restarted and the user will be login by the auto login option. Finally the custom configuration will be removed and the original state of the configuration file will be restored.If GDM in use: the service to be restarted is
gdm3.serviceand the configuration file that should be changed is/etc/gdm3/custom.conf.
Here is the workaround that I'm using. It is ugly and rude, but this approach shall work also within Wayland and GDM (Ubuntu 17.10) if the auto login option works at all.
#!/bin/bash
# NAME: lightdm-auto-login
main()
# If the file '/etc/lightdm/lightdm.conf' exists create a backup copy
[[ -f /etc/lightdm/lightdm.conf ]] && mv /etc/lightdm/lightdm.conf,.bak
# Create autologin configuration for the current $USER = $1
echo -e "[Seat:*]nautologin-user=$1" > /etc/lightdm/lightdm.conf
# Restart 'lightdm' while autologin option is enabled
systemctl restart lightdm.service
# Wait for a moment to complete the login process and remove the conf file
sleep 30 && rm /etc/lightdm/lightdm.conf
# Restore the backup if exists
[[ -f /etc/lightdm/lightdm.conf.bak ]] && mv /etc/lightdm/lightdm.conf.bak,
# Execute the 'main()' function with root privileges in the background 'sudo -b'
# Pass the curent $USER as arg (https://unix.stackexchange.com/a/269080/201297)
sudo -b bash -c "$(declare -f main); main $USER"
The script should be executed as regular user (that belongs to the sudoers group).
The script will create a backup copy of the file
/etc/lightdm/lightdm.conf. Then it will generate a new configuration file with auto login option, enabled for the current user. At this point thelightdmwill be restarted and the user will be login by the auto login option. Finally the custom configuration will be removed and the original state of the configuration file will be restored.If GDM in use: the service to be restarted is
gdm3.serviceand the configuration file that should be changed is/etc/gdm3/custom.conf.
edited Mar 31 at 10:48
answered Mar 31 at 10:06
pa4080
12.2k52256
12.2k52256
add a comment |Â
add a comment |Â
up vote
0
down vote
This works fine for me (from ssh, with lightdm):
$ XAUTHORITY=/var/lib/lightdm/.Xauthority DISPLAY=:0.0 sudo sh -c 'xdotool type "My Password" && xdotool key Return'
add a comment |Â
up vote
0
down vote
This works fine for me (from ssh, with lightdm):
$ XAUTHORITY=/var/lib/lightdm/.Xauthority DISPLAY=:0.0 sudo sh -c 'xdotool type "My Password" && xdotool key Return'
add a comment |Â
up vote
0
down vote
up vote
0
down vote
This works fine for me (from ssh, with lightdm):
$ XAUTHORITY=/var/lib/lightdm/.Xauthority DISPLAY=:0.0 sudo sh -c 'xdotool type "My Password" && xdotool key Return'
This works fine for me (from ssh, with lightdm):
$ XAUTHORITY=/var/lib/lightdm/.Xauthority DISPLAY=:0.0 sudo sh -c 'xdotool type "My Password" && xdotool key Return'
answered May 2 at 17:20
pascalv
1
1
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1020159%2fhow-to-type-into-the-lightdm-login-screen-from-the-command-line%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Which user did you run the commands as? LightDM's X session is probably run under the
lightdmuserâ muru
Mar 29 at 6:19
@muru On Ubuntu 16.04 it is root.
â Adam Ryczkowski
Mar 29 at 7:02