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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
3
down vote

favorite
1












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.










share|improve this question





















  • 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














up vote
3
down vote

favorite
1












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.










share|improve this question





















  • 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












up vote
3
down vote

favorite
1









up vote
3
down vote

favorite
1






1





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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 the lightdm user
    – 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










  • @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










3 Answers
3






active

oldest

votes

















up vote
4
down vote



accepted










Here is an answer that works under Ubuntu 16.04 with lightdm:



  1. Make yourself root to 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.

  2. set XAUTHORITY to point to that file (e.g. export XAUTHORITY=/var/lib/lightdm/.Xauthority)

  3. set DISPLAY to the active display (export DISPLAY=:0)


  4. xdotool should work now. Try



    xdotool type "My super secret password" 
    xdotool key Return






share|improve this answer





























    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 the lightdm will 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.service and the configuration file that should be changed is /etc/gdm3/custom.conf.






    share|improve this answer





























      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'





      share|improve this answer




















        Your Answer







        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "89"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        convertImagesToLinks: true,
        noModals: false,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













         

        draft saved


        draft discarded


















        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






























        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:



        1. Make yourself root to 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.

        2. set XAUTHORITY to point to that file (e.g. export XAUTHORITY=/var/lib/lightdm/.Xauthority)

        3. set DISPLAY to the active display (export DISPLAY=:0)


        4. xdotool should work now. Try



          xdotool type "My super secret password" 
          xdotool key Return






        share|improve this answer


























          up vote
          4
          down vote



          accepted










          Here is an answer that works under Ubuntu 16.04 with lightdm:



          1. Make yourself root to 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.

          2. set XAUTHORITY to point to that file (e.g. export XAUTHORITY=/var/lib/lightdm/.Xauthority)

          3. set DISPLAY to the active display (export DISPLAY=:0)


          4. xdotool should work now. Try



            xdotool type "My super secret password" 
            xdotool key Return






          share|improve this answer
























            up vote
            4
            down vote



            accepted







            up vote
            4
            down vote



            accepted






            Here is an answer that works under Ubuntu 16.04 with lightdm:



            1. Make yourself root to 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.

            2. set XAUTHORITY to point to that file (e.g. export XAUTHORITY=/var/lib/lightdm/.Xauthority)

            3. set DISPLAY to the active display (export DISPLAY=:0)


            4. xdotool should work now. Try



              xdotool type "My super secret password" 
              xdotool key Return






            share|improve this answer














            Here is an answer that works under Ubuntu 16.04 with lightdm:



            1. Make yourself root to 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.

            2. set XAUTHORITY to point to that file (e.g. export XAUTHORITY=/var/lib/lightdm/.Xauthority)

            3. set DISPLAY to the active display (export DISPLAY=:0)


            4. xdotool should work now. Try



              xdotool type "My super secret password" 
              xdotool key Return







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 9 at 10:08









            terdon♦

            62k12127205




            62k12127205










            answered Mar 29 at 7:08









            Adam Ryczkowski

            2,31252150




            2,31252150






















                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 the lightdm will 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.service and the configuration file that should be changed is /etc/gdm3/custom.conf.






                share|improve this answer


























                  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 the lightdm will 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.service and the configuration file that should be changed is /etc/gdm3/custom.conf.






                  share|improve this answer
























                    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 the lightdm will 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.service and the configuration file that should be changed is /etc/gdm3/custom.conf.






                    share|improve this answer














                    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 the lightdm will 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.service and the configuration file that should be changed is /etc/gdm3/custom.conf.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Mar 31 at 10:48

























                    answered Mar 31 at 10:06









                    pa4080

                    12.2k52256




                    12.2k52256




















                        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'





                        share|improve this answer
























                          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'





                          share|improve this answer






















                            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'





                            share|improve this answer












                            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'






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered May 2 at 17:20









                            pascalv

                            1




                            1



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                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













































































                                Popular posts from this blog

                                Unable to execute new pre-installation script (/var/lib/dpkg/tmp.ci/preinst)

                                Running the scala interactive shell from the command line

                                Do not install recommended packages of dependencies