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

    Securing SSH

    Scheduled Pinned Locked Moved IT Discussion
    sshssh keyssecurity
    60 Posts 11 Posters 5.3k 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.
    • DashrenderD
      Dashrender @JaredBusch
      last edited by

      @JaredBusch said in Securing SSH:

      @Dashrender said in Securing SSH:

      So all of the public keys go into that single authorized_keys file?

      It is in the user directory. All of that user's keys are there.

      But again, these are public keys.

      Yeah, I wasn't worried about a security situation... but I'm guessing by making the keys part of the profile on the end controlled device, that is what sets what user is logged in via the key, since there is no username associated with the key itself.
      Just talking this through to myself.

      Thanks.

      JaredBuschJ 1 Reply Last reply Reply Quote 0
      • JaredBuschJ
        JaredBusch @Dashrender
        last edited by

        @Dashrender said in Securing SSH:

        @JaredBusch said in Securing SSH:

        @Dashrender said in Securing SSH:

        So all of the public keys go into that single authorized_keys file?

        It is in the user directory. All of that user's keys are there.

        But again, these are public keys.

        Yeah, I wasn't worried about a security situation... but I'm guessing by making the keys part of the profile on the end controlled device, that is what sets what user is logged in via the key, since there is no username associated with the key itself.
        Just talking this through to myself.

        Thanks.

        The username is specified at login. this has nothing to do with the key.

        ssh user@ip
        

        you can easily use this key for root if you like to be unsecure.

        ssh root@ip
        
        DashrenderD 1 Reply Last reply Reply Quote 1
        • hobbit666H
          hobbit666 @JaredBusch
          last edited by

          @JaredBusch said in Securing SSH:

          This is your friend.

          ssh-copy-id -i ~/.ssh/id_ed25519.pub user@ip
          

          command not found in powershell 🙂 bu that's a windows problem.

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

            @hobbit666 said in Securing SSH:

            @JaredBusch said in Securing SSH:

            This is your friend.

            ssh-copy-id -i ~/.ssh/id_ed25519.pub user@ip
            

            command not found in powershell 🙂 bu that's a windows problem.

            That's because windows doesn't have an ssh-copy-id function. You're expected to know to manually copy the file into .ssh

            JaredBuschJ 1 Reply Last reply Reply Quote 1
            • DashrenderD
              Dashrender @JaredBusch
              last edited by

              @JaredBusch said in Securing SSH:

              @Dashrender said in Securing SSH:

              @JaredBusch said in Securing SSH:

              @Dashrender said in Securing SSH:

              So all of the public keys go into that single authorized_keys file?

              It is in the user directory. All of that user's keys are there.

              But again, these are public keys.

              Yeah, I wasn't worried about a security situation... but I'm guessing by making the keys part of the profile on the end controlled device, that is what sets what user is logged in via the key, since there is no username associated with the key itself.
              Just talking this through to myself.

              Thanks.

              The username is specified at login. this has nothing to do with the key.

              ssh user@ip
              

              you can easily use this key for root if you like to be unsecure.

              ssh root@ip
              

              Thanks, I stand corrected.

              1 Reply Last reply Reply Quote 0
              • JaredBuschJ
                JaredBusch @DustinB3403
                last edited by

                @DustinB3403 said in Securing SSH:

                @hobbit666 said in Securing SSH:

                @JaredBusch said in Securing SSH:

                This is your friend.

                ssh-copy-id -i ~/.ssh/id_ed25519.pub user@ip
                

                command not found in powershell 🙂 bu that's a windows problem.

                That's because windows doesn't have an ssh-copy-id function. You're expected to know to manually copy the file into .ssh

                That's his problem for using a shitty OS, not mine.

                hobbit666H 1 Reply Last reply Reply Quote 4
                • hobbit666H
                  hobbit666 @JaredBusch
                  last edited by

                  @JaredBusch :face_with_stuck-out_tongue_winking_eye: :face_with_stuck-out_tongue_winking_eye: :face_with_stuck-out_tongue_closed_eyes: :face_with_stuck-out_tongue_closed_eyes:
                  I'll try moving to Fedora again at some point.

                  1 Reply Last reply Reply Quote 1
                  • hobbit666H
                    hobbit666
                    last edited by

                    So, I've done the keys and all is working with my Zabbix and Unifi servers. Not disabled password logins yet (apart from root).

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

                      @hobbit666 said in Securing SSH:

                      So, I've done the keys and all is working with my Zabbix and Unifi servers. Not disabled password logins yet (apart from root).

                      If you're keys work, you should disable the password logins.

                      hobbit666H 1 Reply Last reply Reply Quote 0
                      • hobbit666H
                        hobbit666 @DustinB3403
                        last edited by

                        @DustinB3403 I will once i've played around a bit more with changing other settings for SSH.

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

                          @hobbit666 Don't forget that you can set a password on your keys if you really want to have a more secured access process.

                          hobbit666H 1 Reply Last reply Reply Quote 0
                          • hobbit666H
                            hobbit666 @DustinB3403
                            last edited by

                            @DustinB3403 I've already got the password on the keys. I've just not disabled password logins in case i kill something and need to get access :). Planning on removing it once i've "SSH Key's" the other servers.

                            DustinB3403D pmonchoP 2 Replies Last reply Reply Quote 0
                            • DustinB3403D
                              DustinB3403 @hobbit666
                              last edited by

                              @hobbit666 said in Securing SSH:

                              @DustinB3403 I've already got the password on the keys. I've just not disabled password logins in case i kill something and need to get access :). Planning on removing it once i've "SSH Key's" the other servers.

                              Have you confirmed that key based login works? If so, then you login as user@ip and elevate to root. Disable root login period via ssh and only allow elevation.

                              1 Reply Last reply Reply Quote 0
                              • pmonchoP
                                pmoncho @hobbit666
                                last edited by

                                @hobbit666 said in Securing SSH:

                                @DustinB3403 I've already got the password on the keys. I've just not disabled password logins in case i kill something and need to get access :). Planning on removing it once i've "SSH Key's" the other servers.

                                Don't forget, you can still login as root or a admin user on the console. You are only securing ssh.

                                If you want to test, login to the console of the server (stay logged in), change your sshd_config, restart sshd process, test logging in with your keys and/or any other testing you want to do. If all is well, log out of the console.

                                1 Reply Last reply Reply Quote 2
                                • wirestyle22W
                                  wirestyle22 @JaredBusch
                                  last edited by wirestyle22

                                  @JaredBusch said in Securing SSH:

                                  @hobbit666 said in Securing SSH:

                                  @Dashrender To be honest that's my next step is now to make some keys for my laptop, and see how and where they go 🙂
                                  but my guess is in the same authorized_keys file on a separate line

                                  This is your friend.

                                  ssh-copy-id -i ~/.ssh/id_ed25519.pub user@ip
                                  

                                  if you only have a single public key you can simplify it to

                                  ssh-copy-id user@ip
                                  

                                  I specify because my desktop has a few different generated keys.
                                  3ff95aa0-de1f-4a83-b1c3-74c0919f78c8-image.png

                                  How does this fit into disaster recovery plans when you have many hundreds of ssh keys and a large IT team? If one person has 100 keys to various servers and their laptop dies, are you guys using a script to copy the keys per user? Also new user creation or deleting keys when someone leaves

                                  JaredBuschJ coliverC 2 Replies Last reply Reply Quote 1
                                  • JaredBuschJ
                                    JaredBusch @wirestyle22
                                    last edited by

                                    @wirestyle22 said in Securing SSH:

                                    @JaredBusch said in Securing SSH:

                                    @hobbit666 said in Securing SSH:

                                    @Dashrender To be honest that's my next step is now to make some keys for my laptop, and see how and where they go 🙂
                                    but my guess is in the same authorized_keys file on a separate line

                                    This is your friend.

                                    ssh-copy-id -i ~/.ssh/id_ed25519.pub user@ip
                                    

                                    if you only have a single public key you can simplify it to

                                    ssh-copy-id user@ip
                                    

                                    I specify because my desktop has a few different generated keys.
                                    3ff95aa0-de1f-4a83-b1c3-74c0919f78c8-image.png

                                    How does this fit into disaster recovery plans when you have many hundreds of ssh keys and a large IT team? If one person has 100 keys to various servers and their laptop dies, are you guys using a script to copy the keys per user? Also new user creation or deleting keys when someone leaves

                                    No one has 100 keys unless they have 100 desktops.

                                    But yes. you can easily script this.

                                    See:

                                    @scottalanmiller said in Securing SSH:

                                    Correct. We put our public keys into scripts to deploy and have them listed on a wiki, too. So that it is easy to add users to a system.

                                    1 Reply Last reply Reply Quote 1
                                    • coliverC
                                      coliver @wirestyle22
                                      last edited by

                                      @wirestyle22 said in Securing SSH:

                                      @JaredBusch said in Securing SSH:

                                      @hobbit666 said in Securing SSH:

                                      @Dashrender To be honest that's my next step is now to make some keys for my laptop, and see how and where they go 🙂
                                      but my guess is in the same authorized_keys file on a separate line

                                      This is your friend.

                                      ssh-copy-id -i ~/.ssh/id_ed25519.pub user@ip
                                      

                                      if you only have a single public key you can simplify it to

                                      ssh-copy-id user@ip
                                      

                                      I specify because my desktop has a few different generated keys.
                                      3ff95aa0-de1f-4a83-b1c3-74c0919f78c8-image.png

                                      How does this fit into disaster recovery plans when you have many hundreds of ssh keys and a large IT team? If one person has 100 keys to various servers and their laptop dies, are you guys using a script to copy the keys per user? Also new user creation or deleting keys when someone leaves

                                      There is also a way to do a trusted key broker. So you have a single CA that verifies your identity.

                                      stacksofplatesS 1 Reply Last reply Reply Quote 1
                                      • stacksofplatesS
                                        stacksofplates @coliver
                                        last edited by

                                        @coliver said in Securing SSH:

                                        @wirestyle22 said in Securing SSH:

                                        @JaredBusch said in Securing SSH:

                                        @hobbit666 said in Securing SSH:

                                        @Dashrender To be honest that's my next step is now to make some keys for my laptop, and see how and where they go 🙂
                                        but my guess is in the same authorized_keys file on a separate line

                                        This is your friend.

                                        ssh-copy-id -i ~/.ssh/id_ed25519.pub user@ip
                                        

                                        if you only have a single public key you can simplify it to

                                        ssh-copy-id user@ip
                                        

                                        I specify because my desktop has a few different generated keys.
                                        3ff95aa0-de1f-4a83-b1c3-74c0919f78c8-image.png

                                        How does this fit into disaster recovery plans when you have many hundreds of ssh keys and a large IT team? If one person has 100 keys to various servers and their laptop dies, are you guys using a script to copy the keys per user? Also new user creation or deleting keys when someone leaves

                                        There is also a way to do a trusted key broker. So you have a single CA that verifies your identity.

                                        Right there's a few ways to do this. Key management through LDAP, SSH certs with a CA, rotating credentials with something like Vault, etc.

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

                                          @stacksofplates said in Securing SSH:

                                          @coliver said in Securing SSH:

                                          @wirestyle22 said in Securing SSH:

                                          @JaredBusch said in Securing SSH:

                                          @hobbit666 said in Securing SSH:

                                          @Dashrender To be honest that's my next step is now to make some keys for my laptop, and see how and where they go 🙂
                                          but my guess is in the same authorized_keys file on a separate line

                                          This is your friend.

                                          ssh-copy-id -i ~/.ssh/id_ed25519.pub user@ip
                                          

                                          if you only have a single public key you can simplify it to

                                          ssh-copy-id user@ip
                                          

                                          I specify because my desktop has a few different generated keys.
                                          3ff95aa0-de1f-4a83-b1c3-74c0919f78c8-image.png

                                          How does this fit into disaster recovery plans when you have many hundreds of ssh keys and a large IT team? If one person has 100 keys to various servers and their laptop dies, are you guys using a script to copy the keys per user? Also new user creation or deleting keys when someone leaves

                                          There is also a way to do a trusted key broker. So you have a single CA that verifies your identity.

                                          Right there's a few ways to do this. Key management through LDAP, SSH certs with a CA, rotating credentials with something like Vault, etc.

                                          You can do this something like Okta ASA as well.

                                          https://help.okta.com/en/prod/Content/Topics/Adv_Server_Access/docs/asa-overview.htm

                                          1 Reply Last reply Reply Quote 1
                                          • stacksofplatesS
                                            stacksofplates
                                            last edited by

                                            Another really good option is not letting them log directly into the systems at all and forcing them to use a config management tool. So something like Tower or a Jenkins server that logs all of the commands run and has the permissions set there.

                                            scottalanmillerS 1 Reply Last reply Reply Quote 4
                                            • 1
                                            • 2
                                            • 3
                                            • 3 / 3
                                            • First post
                                              Last post