Skip to content

Commit

Permalink
Use _sish as the dns prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomika committed Aug 30, 2024
1 parent dd019ce commit b06d594
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
10 changes: 3 additions & 7 deletions docs/posts/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@ sish supports allowing users to bring custom domains to the service, but SSH key
auth is required to be enabled. To use this feature, you must setup TXT and
CNAME/A records for the domain/subdomain you would like to use for your
forwarded connection. The CNAME/A record must point to the domain or IP that is
hosting sish. The TXT record must be be a `key=val` string that looks like:
hosting sish. The TXT record must be for `_sish.customdomain` and contain an ssh key fingerprint.

```text
sish=SSHKEYFINGERPRINT
```

Where `SSHKEYFINGERPRINT` is the fingerprint of the key used for logging into
the server. You can set multiple TXT records and sish will check all of them to
You must use the fingerprint of the key used for logging into the server.
You can set multiple TXT records and sish will check all of them to
ensure at least one is a match. You can retrieve your key fingerprint by
running:

Expand Down
14 changes: 5 additions & 9 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (

const (
// sishDNSPrefix is the prefix used for DNS TXT records.
sishDNSPrefix = "sish="
sishDNSPrefix = "_sish"

// Prefix used for defining wildcard host matchers.
wildcardPrefix = "*."
Expand Down Expand Up @@ -638,16 +638,12 @@ func verifyDNS(addr string, sshConn *SSHConnection) (bool, string, error) {
return false, "", nil
}

records, err := net.LookupTXT(addr)
records, err := net.LookupTXT(fmt.Sprintf("%s.%s", sishDNSPrefix, addr))

for _, v := range records {
if strings.HasPrefix(v, sishDNSPrefix) {
dnsPubKeyFingerprint := strings.TrimSpace(strings.TrimPrefix(v, sishDNSPrefix))

match := sshConn.SSHConn.Permissions.Extensions["pubKeyFingerprint"] == dnsPubKeyFingerprint
if match {
return match, dnsPubKeyFingerprint, err
}
match := sshConn.SSHConn.Permissions.Extensions["pubKeyFingerprint"] == v
if match {
return match, v, err
}
}

Expand Down

0 comments on commit b06d594

Please sign in to comment.