public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Cc: Esi Y <esiy0676+proxmox@gmail.com>
Subject: Re: [pve-devel] [PATCH cluster 2/4] fix #4886: SSH: pin node's host key if available
Date: Mon, 15 Jan 2024 12:51:48 +0100 (CET)	[thread overview]
Message-ID: <1169764233.3317.1705319508414@webmail.proxmox.com> (raw)
In-Reply-To: <mailman.431.1705316883.335.pve-devel@lists.proxmox.com>

> On Thu, Jan 11, 2024 at 11:51:16AM +0100, Fabian Grünbichler wrote:
> > if the target node has already stored their SSH host key on pmxcfs, pin it and
> > ignore the global known hosts information.
> > 
> > Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> > ---
> >  src/PVE/SSHInfo.pm | 15 ++++++++++++++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/PVE/SSHInfo.pm b/src/PVE/SSHInfo.pm
> > index c351148..fad23bf 100644
> > --- a/src/PVE/SSHInfo.pm
> > +++ b/src/PVE/SSHInfo.pm
> > @@ -49,11 +49,24 @@ sub get_ssh_info {
> >  
> >  sub ssh_info_to_command_base {
> >      my ($info, @extra_options) = @_;
> > +
> > +    my $nodename = $info->{name};
> > +
> > +    my $known_hosts_file = "/etc/pve/nodes/$nodename/ssh_known_hosts";
> > +    my $known_hosts_options = undef;
> > +    if (-f $known_hosts_file) {
> > +	$known_hosts_options = [
> > +	    '-o', "UserKnownHostsFile=$known_hosts_file",
> > +	    '-o', 'GlobalKnownHostsFile=none',
> 
> why does Global need to be none, even as this only applies if the snippet exists?

because we want to only let SSH look at our pinned file, not the regular one, which might contain bogus information. since our pinned file contains an entry for our host key alias which must match, the global file can never improve the situation, but it can cause a verification failure.

> > +	];
> > +    } 
> > +
> >      return [
> >  	'/usr/bin/ssh',
> >  	'-e', 'none',
> >  	'-o', 'BatchMode=yes',
> > -	'-o', 'HostKeyAlias='.$info->{name},
> > +	'-o', 'HostKeyAlias='.$nodename,
> > +	defined($known_hosts_options) ? @$known_hosts_options : (),
> >  	@extra_options
> >      ];
> >  }
> > -- 
> > 2.39.2
> > 
> > 
> > 
> > _______________________________________________
> > pve-devel mailing list
> > pve-devel@lists.proxmox.com
> > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




  parent reply	other threads:[~2024-01-15 11:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11 10:51 [pve-devel] [PATCH cluster/manager/storage/docs 0/9] fix #4886: improve SSH handling Fabian Grünbichler
2024-01-11 10:51 ` [pve-devel] [PATCH cluster 1/4] fix #4886: write node SSH hostkey to pmxcfs Fabian Grünbichler
2024-01-11 10:51 ` [pve-devel] [PATCH cluster 2/4] fix #4886: SSH: pin node's host key if available Fabian Grünbichler
     [not found]   ` <mailman.431.1705316883.335.pve-devel@lists.proxmox.com>
2024-01-15 11:51     ` Fabian Grünbichler [this message]
     [not found]       ` <mailman.436.1705329114.335.pve-devel@lists.proxmox.com>
2024-01-16  9:00         ` Fabian Grünbichler
2024-01-11 10:51 ` [pve-devel] [PATCH cluster 3/4] ssh: expose SSH options on their own Fabian Grünbichler
2024-01-11 10:51 ` [pve-devel] [PATCH cluster 4/4] pvecm: stop merging SSH known hosts by default Fabian Grünbichler
2024-01-11 10:51 ` [pve-devel] [PATCH docs 1/2] ssh: make pitfalls a regular section instead of block Fabian Grünbichler
2024-01-11 10:51 ` [pve-devel] [PATCH docs 2/2] ssh: document PVE-specific setup Fabian Grünbichler
     [not found]   ` <mailman.409.1705062826.335.pve-devel@lists.proxmox.com>
2024-01-12 12:40     ` Fabian Grünbichler
2024-01-11 10:51 ` [pve-devel] [PATCH manager 1/2] vnc: use SSH command helper Fabian Grünbichler
2024-01-11 10:51 ` [pve-devel] [PATCH manager 2/2] pvesh: " Fabian Grünbichler
2024-01-11 10:51 ` [pve-devel] [PATCH storage 1/1] upload: use SSH helper to get ssh/scp options Fabian Grünbichler
2024-01-12 12:12 ` [pve-devel] [PATCH cluster/manager/storage/docs 0/9] fix #4886: improve SSH handling Fabian Grünbichler
2024-01-15 15:53 ` Hannes Dürr
2024-01-16 10:34   ` Thomas Lamprecht
2024-01-16 10:40     ` Fabian Grünbichler
2024-01-16 10:49       ` Thomas Lamprecht
2024-01-16 11:58     ` Hannes Dürr
2024-04-19  7:11 ` [pve-devel] applied-series: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1169764233.3317.1705319508414@webmail.proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=esiy0676+proxmox@gmail.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal