ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Cannot SSH using public key

    Scheduled Pinned Locked Moved IT Discussion
    ssh keysssh
    33 Posts 4 Posters 2.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DustinB3403D
      DustinB3403 @IRJ
      last edited by

      @IRJ Just login as the scan_user and then run the ssh-keygen process if you want to run it under that user account.

      1 Reply Last reply Reply Quote 1
      • DustinB3403D
        DustinB3403
        last edited by

        Literally su scan_user
        ssh-keygen -t rsa

        IRJI 1 Reply Last reply Reply Quote 0
        • IRJI
          IRJ @DustinB3403
          last edited by

          @DustinB3403 said in Cannot SSH using public key:

          Literally su scan_user
          ssh-keygen -t rsa

          yeah doing it now.

          1 Reply Last reply Reply Quote 0
          • IRJI
            IRJ
            last edited by

            Still getting permission denied when trying to login even via ssh-copy-id

            1 Reply Last reply Reply Quote 0
            • IRJI
              IRJ
              last edited by

              I want to throw something right now!!! This should be so basic!!! ugh

              1 Reply Last reply Reply Quote 0
              • DustinB3403D
                DustinB3403
                last edited by

                @IRJ okay lets take a step back.

                Can you ssh into this unit as scan_user ?

                ssh scan_user@x.x.x.x ?

                IRJI 1 Reply Last reply Reply Quote 0
                • IRJI
                  IRJ @DustinB3403
                  last edited by

                  @DustinB3403 said in Cannot SSH using public key:

                  @IRJ okay lets take a step back.

                  Can you ssh into this unit as scan_user ?

                  ssh scan_user@x.x.x.x ?

                  I cannot right now because I have these lines in sshd

                  Match User scan_user
                      PasswordAuthentication no
                  
                  DustinB3403D 1 Reply Last reply Reply Quote 0
                  • DustinB3403D
                    DustinB3403 @IRJ
                    last edited by DustinB3403

                    @IRJ said in Cannot SSH using public key:

                    @DustinB3403 said in Cannot SSH using public key:

                    @IRJ okay lets take a step back.

                    Can you ssh into this unit as scan_user ?

                    ssh scan_user@x.x.x.x ?

                    I cannot right now because I have these lines in sshd

                    Match User scan_user
                        PasswordAuthentication no
                    

                    Then you would never be able to copy the key to this system. You need password auth first, which can be disabled once you have working keys.


                    Unless you manually copy and paste the key to this system, which is stupid.

                    Just enable passauth for the time, setup the key with ssh-copy-id and then turn off the passwordauth.

                    IRJI 1 Reply Last reply Reply Quote 0
                    • IRJI
                      IRJ @DustinB3403
                      last edited by

                      @DustinB3403 said in Cannot SSH using public key:

                      @IRJ said in Cannot SSH using public key:

                      @DustinB3403 said in Cannot SSH using public key:

                      @IRJ okay lets take a step back.

                      Can you ssh into this unit as scan_user ?

                      ssh scan_user@x.x.x.x ?

                      I cannot right now because I have these lines in sshd

                      Match User scan_user
                          PasswordAuthentication no
                      

                      Then you would never be able to copy the key to this system. You need password auth first, which can be disabled once you have working keys.

                      Ok. I commented out restarted sshd and I was able to login with password.

                      DustinB3403D 1 Reply Last reply Reply Quote 0
                      • DustinB3403D
                        DustinB3403 @IRJ
                        last edited by

                        @IRJ said in Cannot SSH using public key:

                        @DustinB3403 said in Cannot SSH using public key:

                        @IRJ said in Cannot SSH using public key:

                        @DustinB3403 said in Cannot SSH using public key:

                        @IRJ okay lets take a step back.

                        Can you ssh into this unit as scan_user ?

                        ssh scan_user@x.x.x.x ?

                        I cannot right now because I have these lines in sshd

                        Match User scan_user
                            PasswordAuthentication no
                        

                        Then you would never be able to copy the key to this system. You need password auth first, which can be disabled once you have working keys.

                        Ok. I commented out restarted sshd and I was able to login with password.

                        Okay, now perform the ssh-copy-id command.

                        1 Reply Last reply Reply Quote 0
                        • DustinB3403D
                          DustinB3403
                          last edited by

                          @IRJ ?

                          IRJI 1 Reply Last reply Reply Quote 1
                          • IRJI
                            IRJ @DustinB3403
                            last edited by

                            @DustinB3403 said in Cannot SSH using public key:

                            @IRJ ?

                            I finally got it working! I commented that out and it is now working. I was also able to turn off password authentication for that account.

                            The issue was in my sshd_config

                            AuthorizedKeysFile  %h/.ssh/authorized_keys
                            
                            1 Reply Last reply Reply Quote 0
                            • IRJI
                              IRJ
                              last edited by

                              Gonna have to do this on another server for a sanity check though lol

                              1 Reply Last reply Reply Quote 0
                              • IRJI
                                IRJ
                                last edited by

                                Ok sanity check complete. Working on another system now. My only issue was AuthorizedKeysFile

                                1 Reply Last reply Reply Quote 0
                                • IRJI
                                  IRJ
                                  last edited by

                                  RSA key working on Nessus, too. Thanks @DustinB3403 for calming me down

                                  DustinB3403D 1 Reply Last reply Reply Quote 2
                                  • DustinB3403D
                                    DustinB3403 @IRJ
                                    last edited by

                                    @IRJ said in Cannot SSH using public key:

                                    RSA key working on Nessus, too. Thanks @DustinB3403 for calming me down

                                    You're welcome.

                                    1 Reply Last reply Reply Quote 0
                                    • 1
                                    • 2
                                    • 2 / 2
                                    • First post
                                      Last post