Skip to content

Commit c0171a0

Browse files
rbishopsfc-gh-rbishopwill
authored
Use SSH certificates for connection to tail logs (#184)
SSH certificates have the benefit of having time range validity builtin. Testing: - Verified cb logs and cb scopes work Co-authored-by: Richard Bishop <[email protected]> Co-authored-by: Will Leinweber <[email protected]>
1 parent 32ab944 commit c0171a0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/cb/logs.cr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ module CB
2020

2121
socket = TCPSocket.new(tk.host, 22, connect_timeout: 1)
2222
ssh = SSH2::Session.new(socket)
23-
ssh.login_with_data("cormorant", tk.private_key, tk.public_key)
23+
24+
if tk.certificate.presence
25+
ssh.login_with_data("cormorant", tk.private_key, tk.certificate.to_s)
26+
else
27+
ssh.login_with_data("cormorant", tk.private_key, tk.public_key)
28+
end
2429

2530
ch = ssh.open_session
2631
ch.shell

src/cb/tempkey.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module CB
2-
record Tempkey, host : String, private_key : String, public_key : String, cluster_id : String, team_id : String, expires_at : Time do
2+
record Tempkey, host : String, private_key : String, public_key : String, certificate : String?, cluster_id : String, team_id : String, expires_at : Time do
33
Cacheable.include key: cluster_id
44

55
def self.for_cluster(cluster_id : Identifier, client) : Tempkey

0 commit comments

Comments
 (0)