Skip to content

feat: add key algorithm into SSHEndpoint object #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/machines/ssh_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type SSHEndpoint struct {
ProxyID string `json:"ProxyId,omitempty"`
Port int
URI *url.URL `json:"Uri"`
KeyAlgo string

endpoint
}
Expand Down Expand Up @@ -62,6 +63,11 @@ func (s *SSHEndpoint) GetFingerprint() string {
return s.Fingerprint
}

// GetKeyAlgo returns the algorithm used with this SSH endpoints fingerprint
func (s *SSHEndpoint) GetKeyAlgo() string {
return s.KeyAlgo
}

// GetHost returns the host associated with this SSH endpoint.
func (s *SSHEndpoint) GetHost() string {
return s.Host
Expand All @@ -82,6 +88,7 @@ func (s *SSHEndpoint) MarshalJSON() ([]byte, error) {
Port int
ProxyID string `json:"ProxyId,omitempty"`
URI string `json:"Uri"`
KeyAlgo string
resources.Resource
}{
AccountID: s.AccountID,
Expand All @@ -92,6 +99,7 @@ func (s *SSHEndpoint) MarshalJSON() ([]byte, error) {
Port: s.Port,
ProxyID: s.ProxyID,
URI: s.URI.String(),
KeyAlgo: s.KeyAlgo,
Resource: s.Resource,
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/machines/ssh_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func CreateTestSSHEndpoint(t *testing.T) *SSHEndpoint {
}
proxyID := "proxy-id"
port := 22
keyalgo := "ssh-rsa"

sshEndpoint := NewSSHEndpoint(host, port, fingerprint)
require.NoError(t, sshEndpoint.Validate())
Expand All @@ -35,6 +36,7 @@ func CreateTestSSHEndpoint(t *testing.T) *SSHEndpoint {
sshEndpoint.ModifiedOn = &lastModifiedOn
sshEndpoint.Links = links
sshEndpoint.ProxyID = proxyID
sshEndpoint.KeyAlgo = keyalgo

require.NoError(t, sshEndpoint.Validate())

Expand Down Expand Up @@ -73,6 +75,7 @@ const sshEndpointAsJSON string = `{
"Host": "example.com",
"Port": 22,
"Fingerprint": "22:22:22:22:22:22:22:22:22:22:22:22:22:22:22",
"KeyAlgo": "ssh-rsa",
"Uri": "ssh://example.com:22/",
"ProxyId": "proxy-id",
"DotNetCorePlatform": "linux-x64",
Expand Down