Skip to content
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

Use of insecure HostKeyCallback implementation #60

Closed
wants to merge 4 commits into from
Closed

Use of insecure HostKeyCallback implementation #60

wants to merge 4 commits into from

Conversation

riteshsonawane1372
Copy link
Contributor

@riteshsonawane1372 riteshsonawane1372 commented Jan 8, 2023

Tasks

Use of insecure HostKeyCallback implementation

Solution ✔️

HostKeyCallback: ssh.HostKeyCallback(
	func(hostname string, remote net.Addr, key ssh.PublicKey) error {
		return nil
}),

Screenshots 🖼️

Note to reviewers 📓

@dipankardas011
Copy link
Member

@riteshsonawane1372 are there no other methods available?

@riteshsonawane1372
Copy link
Contributor Author

FixedHostKey : When the allow list contains only a single host key

HostKeyCallback: ssh.FixedHostKey(publicKey),

@riteshsonawane1372
Copy link
Contributor Author

func secureHostKeyCallback() {
	publicKeyBytes, _ := ioutil.ReadFile("allowed_hostkey.pub")
	publicKey, _ := ssh.ParsePublicKey(publicKeyBytes)

	_ = &ssh.ClientConfig{
		User:            "username",
		Auth:            []ssh.AuthMethod{nil},
		HostKeyCallback: ssh.FixedHostKey(publicKey),
	}
}

@dipankardas011
Copy link
Member

@riteshsonawane1372 could you replace the password-based auth with ssh key auth?
if you are up for it

Comment on lines 273 to 274
//HostKeyCallback: hostKeyCallback,
// FIXME: Insecure Ignore should be replaced with secure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the comment

Comment on lines 220 to 223
HostKeyCallback: ssh.HostKeyCallback(
func(hostname string, remote net.Addr, key ssh.PublicKey) error {
return nil
}),

Check failure

Code scanning / CodeQL

Use of insecure HostKeyCallback implementation

Configuring SSH ClientConfig with insecure HostKeyCallback implementation from [this source](1).
Comment on lines 275 to 278
HostKeyCallback: ssh.HostKeyCallback(
func(hostname string, remote net.Addr, key ssh.PublicKey) error {
return nil
}),

Check failure

Code scanning / CodeQL

Use of insecure HostKeyCallback implementation

Configuring SSH ClientConfig with insecure HostKeyCallback implementation from [this source](1).
@riteshsonawane1372
Copy link
Contributor Author

@riteshsonawane1372 could you replace the password-based auth with ssh key auth? if you are up for it

	signer, _ := ssh.ParsePrivateKey([]byte(password))
	config := &ssh.ClientConfig{
		User: "root",
		Auth: []ssh.AuthMethod{
			ssh.PublicKeys(signer),
		},
		HostKeyCallback: ssh.HostKeyCallback(
			func(hostname string, remote net.Addr, key ssh.PublicKey) error {
				return nil
		

@dipankardas011
Copy link
Member

dipankardas011 commented Jan 9, 2023

@riteshsonawane1372 could you replace the password-based auth with ssh key auth? if you are up for it

	signer, _ := ssh.ParsePrivateKey([]byte(password))
	config := &ssh.ClientConfig{
		User: "root",
		Auth: []ssh.AuthMethod{
			ssh.PublicKeys(signer),
		},
		HostKeyCallback: ssh.HostKeyCallback(
			func(hostname string, remote net.Addr, key ssh.PublicKey) error {
				return nil
		

If we can move to private key Auth
We have to create sshkeypair function and delete when delete cluster
Get the key and save it to ksctl cluster folder and use it to ssh
Ig that will match with rest of the cloud providers
@AvineshTripathi @kranurag7 your thoughts

@dipankardas011
Copy link
Member

@riteshsonawane1372
Copy link
Contributor Author

@riteshsonawane1372 could you replace the password-based auth with ssh key auth? if you are up for it

	signer, _ := ssh.ParsePrivateKey([]byte(password))
	config := &ssh.ClientConfig{
		User: "root",
		Auth: []ssh.AuthMethod{
			ssh.PublicKeys(signer),
		},
		HostKeyCallback: ssh.HostKeyCallback(
			func(hostname string, remote net.Addr, key ssh.PublicKey) error {
				return nil
		

If we can move to private key Auth We have to create sshkeypair function and delete when delete cluster Get the key and save it to ksctl cluster folder and use it to ssh Ig that will match with rest of the cloud providers @AvineshTripathi @kranurag7 your thoughts

Can you describe a bit ?

@dipankardas011
Copy link
Member

@riteshsonawane1372 could you replace the password-based auth with ssh key auth? if you are up for it

	signer, _ := ssh.ParsePrivateKey([]byte(password))
	config := &ssh.ClientConfig{
		User: "root",
		Auth: []ssh.AuthMethod{
			ssh.PublicKeys(signer),
		},
		HostKeyCallback: ssh.HostKeyCallback(
			func(hostname string, remote net.Addr, key ssh.PublicKey) error {
				return nil
		

If we can move to private key Auth We have to create sshkeypair function and delete when delete cluster Get the key and save it to ksctl cluster folder and use it to ssh Ig that will match with rest of the cloud providers @AvineshTripathi @kranurag7 your thoughts

Can you describe a bit ?

ig it will be clear if you can check the Issue created still any doubt we can discuss

@dipankardas011
Copy link
Member

dipankardas011 commented Jan 15, 2023

@riteshsonawane1372 you are working on main branch do checkout to a different branch
I am closing this PR you can create a another PR as this PR will break the main branch code
ig some miscommunication between us
we can communicate what needs to be done (i.e. the workflow and how to change the src code) 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants