Skip to content

Commit a2fd673

Browse files
committed
Split public keys from auth'd_keys
1 parent 4ce3adb commit a2fd673

6 files changed

Lines changed: 74 additions & 34 deletions

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ man 5 sshd_config
120120
(<kbd>Ctrl</kbd>+<kbd>R</kbd> or
121121
<kbd>Cmd</kbd>+<kbd>R</kbd>)
122122

123-
Public keys are also associated with this syntax,
124-
since the *authorized_keys* format
125-
is basically a strict superset of them.
126-
127123
For file format information,
128124
consult `man` pages on the web
129125
([Linux][man-linux-authorized-keys],

syntax/Authorized Keys.sublime-syntax

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,24 @@
66
name: Authorized Keys
77
scope: source.authorized_keys
88
version: 2
9-
extends: SSH Crypto.sublime-syntax
9+
extends: Public Key.sublime-syntax
1010

1111
file_extensions:
1212
- authorized_keys
13-
- pub
1413

1514
hidden_file_extensions:
1615
- authorized_keys2
1716

1817
contexts:
19-
main:
20-
- include: comments-number-sign
21-
- match: ^
22-
push:
23-
- meta_scope: meta.line.authorized-key.authorized_keys
24-
- include: pop-before-nl
25-
- include: pop-nl
26-
- include: ssh-key-types
27-
- include: ssh-fingerprint-with-label
28-
- include: flag-options
29-
- include: value-options
30-
- include: strings
31-
- match: =
32-
scope: keyword.operator.assignment.authorized_keys
33-
- include: punctuation-comma-sequence
18+
19+
restrictions:
20+
- meta_prepend: true
21+
- include: flag-options
22+
- include: value-options
23+
- include: strings
24+
- match: =
25+
scope: keyword.operator.assignment.authorized_keys
26+
- include: punctuation-comma-sequence
3427

3528
flag-options:
3629
- match: (?:no-)?(?:pty|user-rc|(?:agent|port|X11)-forwarding)

syntax/Public Key.sublime-syntax

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
%YAML 1.2
2+
---
3+
# https://www.sublimetext.com/docs/syntax.html
4+
name: Public Key
5+
scope: source.pubkey
6+
version: 2
7+
extends: SSH Crypto.sublime-syntax
8+
9+
file_extensions:
10+
- pub
11+
12+
contexts:
13+
main:
14+
- include: comments-number-sign
15+
- match: ^(?=\S)
16+
push: [key, restrictions]
17+
18+
key:
19+
- meta_scope: meta.line.key.pubkey
20+
- include: pop-before-nl
21+
- include: ssh-key-types
22+
- include: ssh-fingerprint-with-label
23+
24+
restrictions:
25+
- include: else-pop
26+
- include: pop-before-nl

syntax/SSH Common.sublime-syntax

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ contexts:
259259
- match: (?=\n)
260260
pop: 1
261261

262+
else-pop:
263+
- match: (?=\S)
264+
pop: 1
265+
262266
###############################################################################
263267

264268
variables:

test/syntax_test_authorized_keys.authorized_keys

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
#^^^^^^^^ comment.line.number-sign.ssh.common
66

77
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHeDxE1jPGCLo51RSF7CeJbp4raIc3xo6TBiqkz4WRWI you@example.com
8-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key
9-
# ^ - meta.line.authorized-key
8+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
9+
# ^ - meta.line.key.pubkey
1010
# ^^^^^^^^^ support.type.key-type
1111
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.other.fingerprint
1212
# ^^^^^^^^^^^^^^^ meta.annotation.identifier string.unquoted
1313
# @@@@@@@@@@@@@@@ local-definition "Annotation: you@example.com"
1414

1515
# Comments allowed at start of line
1616
ssh-rsa AAAAB3NzaLiPk== user@example.net
17-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
17+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
1818
#^^^^^^ support.type.key-type
1919
# ^^^^^^^^^^^^^^^ variable.other.fingerprint.ssh.common
2020
# ^^^^^^^^^^^^^^^^ meta.annotation.identifier.ssh.common string.unquoted.ssh.common
2121
# ^^^ - meta.annotation - string
2222
# @@@@@@@@@@@@@@@@ local-definition "Annotation: user@example.net"
2323
from="*.sales.example.net,!pc.sales.example.net" ssh-rsa AAAAB3N9Q== john@example.net
24-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
24+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
2525
#^^^ keyword.other.authorized_keys
2626
# ^ keyword.operator.assignment.authorized_keys
2727
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.authorized_keys
@@ -35,7 +35,7 @@ from="*.sales.example.net,!pc.sales.example.net" ssh-rsa AAAAB3N9Q== john@exampl
3535
# ^^^^^^^^^^^^^^^^ meta.annotation.identifier.ssh.common string.unquoted.ssh.common
3636
# @@@@@@@@@@@@@@@@ local-definition "Annotation: john@example.net"
3737
command="dump /home",no-pty,no-port-forwarding ssh-rsa AAAAC3N51R== example.net
38-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
38+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
3939
#^^^^^^ keyword.other.authorized_keys
4040
# ^ keyword.operator.assignment.authorized_keys
4141
# ^ string.quoted.double.authorized_keys punctuation.definition.string.begin.authorized_keys
@@ -54,7 +54,7 @@ command="dump /home",no-pty,no-port-forwarding ssh-rsa AAAAC3N51R== example.net
5454
# @@@@ reference
5555
# @@@@@@@@@@@ local-definition "Annotation: example.net"
5656
permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-rsa AAAAB3N21S==
57-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
57+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
5858
#^^^^^^^^^ keyword.other.authorized_keys
5959
# ^ keyword.operator.assignment.authorized_keys
6060
# ^^^^^^^^^^^^^^ string.quoted.double.authorized_keys
@@ -75,7 +75,7 @@ permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-rsa AAAAB3N21S==
7575
# ^^^^^^^ support.type.key-type.ssh.crypto
7676
# ^^^^^^^^^^^^ variable.other.fingerprint.ssh.common
7777
permitlisten="localhost:8080",permitopen="localhost:22000",permitlisten="8081" ssh-rsa AAAAB3N21S==
78-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
78+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
7979
#^^^^^^^^^^^ keyword.other.authorized_keys
8080
# ^ keyword.operator.assignment.authorized_keys
8181
# ^^^^^^^^^^^^^^^^ string.quoted.double.authorized_keys
@@ -103,7 +103,7 @@ permitlisten="localhost:8080",permitopen="localhost:22000",permitlisten="8081" s
103103
# ^^^^^^^ support.type.key-type.ssh.crypto
104104
# ^^^^^^^^^^^^ variable.other.fingerprint.ssh.common
105105
tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAAB3N21S== jane@example.net
106-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
106+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
107107
#^^^^^ keyword.other.authorized_keys
108108
# ^ keyword.operator.assignment.authorized_keys
109109
# ^^^ string.quoted.double.authorized_keys
@@ -126,7 +126,7 @@ tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAAB3N21S== jane@example.net
126126
# @@ reference
127127
# @@@@@@@@@@@@@@@@ local-definition "Annotation: jane@example.net"
128128
restrict,command="uptime" ssh-rsa AAAAB3N21S== user@example.net
129-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
129+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
130130
#^^^^^^^ keyword.other.authorized_keys
131131
# ^ punctuation.separator.sequence.ssh.common
132132
# ^^^^^^^ keyword.other.authorized_keys
@@ -140,7 +140,7 @@ restrict,command="uptime" ssh-rsa AAAAB3N21S== user@example.net
140140
# @@@@@@ reference
141141
# @@@@@@@@@@@@@@@@ local-definition "Annotation: user@example.net"
142142
restrict,pty,command="nethack" ssh-rsa AAAAB3N21S== user@example.net
143-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
143+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
144144
#^^^^^^^ keyword.other.authorized_keys
145145
# ^ punctuation.separator.sequence.ssh.common
146146
# ^^^ keyword.other.authorized_keys
@@ -156,14 +156,14 @@ restrict,pty,command="nethack" ssh-rsa AAAAB3N21S== user@example.net
156156
# @@@@@@@ reference
157157
# @@@@@@@@@@@@@@@@ local-definition "Annotation: user@example.net"
158158
no-touch-required sk-ecdsa-sha2-nistp256@openssh.com AAAAB3N21S== user@example.net
159-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
159+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
160160
#^^^^^^^^^^^^^^^^ keyword.other.authorized_keys
161161
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ support.type.key-type
162162
# ^^^^^^^^^^^^ variable.other.fingerprint.ssh.common
163163
# ^^^^^^^^^^^^^^^^ meta.annotation.identifier.ssh.common string.unquoted.ssh.common
164164
# @@@@@@@@@@@@@@@@ local-definition "Annotation: user@example.net"
165165
expiry-time="20190606" ssh-rsa AAAAB3N21S== user@example.net
166-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
166+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
167167
#^^^^^^^^^^ keyword.other.authorized_keys
168168
# ^ keyword.operator.assignment.authorized_keys
169169
# ^^^^^^^^^^ string.quoted.double.authorized_keys
@@ -175,7 +175,7 @@ expiry-time="20190606" ssh-rsa AAAAB3N21S== user@example.net
175175
# ^^^^^^^^^^^^^^^^ meta.annotation.identifier.ssh.common string.unquoted.ssh.common
176176
# @@@@@@@@@@@@@@@@ local-definition "Annotation: user@example.net"
177177
environment="NAME=value",environment="NAME2=value2" ssh-rsa AAAAB3N21S==
178-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.authorized-key.authorized_keys
178+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
179179
#^^^^^^^^^^ keyword.other.authorized_keys
180180
# ^ keyword.operator.assignment.authorized_keys
181181
# ^^^^^^^^^^^^ string.quoted.double.authorized_keys

test/syntax_test_public_key.pub

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SYNTAX TEST "Packages/SSH Config/syntax/Public Key.sublime-syntax"
2+
3+
# Comment
4+
# <- comment.line.number-sign.ssh.common punctuation.definition.comment.ssh.common
5+
#^^^^^^^^ comment.line.number-sign.ssh.common
6+
7+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHeDxE1jPGCLo51RSF7CeJbp4raIc3xo6TBiqkz4WRWI you@example.com
8+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
9+
# ^ - meta.line.authorized-key
10+
# ^^^^^^^^^ support.type.key-type
11+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.other.fingerprint
12+
# ^^^^^^^^^^^^^^^ meta.annotation.identifier string.unquoted
13+
14+
# Comments allowed at start of line
15+
ssh-rsa AAAAB3NzaLiPk== user@example.net
16+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.line.key.pubkey
17+
#^^^^^^ support.type.key-type.ssh.crypto
18+
# ^^^^^^^^^^^^^^^ variable.other.fingerprint.ssh.common
19+
# ^^^^^^^^^^^^^^^^ meta.annotation.identifier.ssh.common string.unquoted.ssh.common
20+
# ^ punctuation.separator.sequence.ssh.common
21+
# ^^^ - meta.annotation - string

0 commit comments

Comments
 (0)