puppet SSHD port based on hostname

50 views
Skip to first unread message

John

unread,
Aug 22, 2017, 12:36:15 PM8/22/17
to Puppet Users
I've pulled down the SAZ SSH module and implemented across my network.  It works great.

However, I need to implement the following change:

If hostname = host1 or host2 or host3
  then
    port = 4444
fi

I just want to change the default sshd port for a few hosts.

How do I do that?
    


John Baird

unread,
Aug 22, 2017, 2:41:06 PM8/22/17
to Puppet Users
It looks like you should be able to pass it as a Hash of "options"... 

John

unread,
Aug 22, 2017, 5:37:35 PM8/22/17
to Puppet Users
So I added the following to sshd_config.erb

<%- if hostname = MyHost -%>
Port = 4444
<%- end -%>

But it did not provide the expected results.  The puppet run finished cleanly, but the sshd_config remained unchanged.

Does that syntax look alright?

TIA

John Baird

unread,
Aug 22, 2017, 9:29:52 PM8/22/17
to Puppet Users
Honestly, I believe you would benefit from reading this over a bit...

Pete Brown

unread,
Aug 25, 2017, 6:58:18 AM8/25/17
to Puppet Users
That is pretty easy to do with hiera.
It’s too complex to explain in an email so i would recommend looking up the docs for it.
This is the best olace to start.
If you aren’t using puppet 5 just switch to the version you are using.


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/4a22f5df-272b-4ce6-9cad-fd60e564440f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John

unread,
Aug 25, 2017, 11:07:31 PM8/25/17
to Puppet Users
So, I agree this is doable in Hiera.  However, I think for the SAZ SSH module, it would be better for me to include it in the sshd_config.erb.

I've added the following to sshd_config.:

<%- if ServerName == myhost -%>
Port = 9999
<%- end -%>

Puppet run finishes with no errors, but /etc/ssh/sshd_config does not the port setting at all.

I've tried different variations of the command above with no luck.

Am I even in the ball park?  It seems this should doable in the sshd_config.erb.  Any advice would be greatly appreciated.

On Tuesday, August 22, 2017 at 12:36:15 PM UTC-4, John wrote:

Rob Nelson

unread,
Aug 26, 2017, 12:33:29 AM8/26/17
to puppet...@googlegroups.com
If you're using saz/ssh, just add this to the 'options' parameter (hash) of ssh::server. Anything that doesn't have a specific parameter can be implemented there. 

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Rob Nelson

Pete Brown

unread,
Aug 27, 2017, 7:19:40 AM8/27/17
to puppet...@googlegroups.com
On Fri, 25 Aug 2017 at 23:07, John <sami....@gmail.com> wrote:
So, I agree this is doable in Hiera.  However, I think for the SAZ SSH module, it would be better for me to include it in the sshd_config.erb.

Why?
It’s a simple solution to do it in hiera.

You are making th problem more complex by changing the template.


I've added the following to sshd_config.:

<%- if ServerName == myhost -%>
Port = 9999
<%- end -%>

Puppet run finishes with no errors, but /etc/ssh/sshd_config does not the port setting at all.

I've tried different variations of the command above with no luck.

Am I even in the ball park?  It seems this should doable in the sshd_config.erb.  Any advice would be greatly appreciated.

On Tuesday, August 22, 2017 at 12:36:15 PM UTC-4, John wrote:
I've pulled down the SAZ SSH module and implemented across my network.  It works great.

However, I need to implement the following change:

If hostname = host1 or host2 or host3
  then
    port = 4444
fi

I just want to change the default sshd port for a few hosts.

How do I do that?
    


Reply all
Reply to author
Forward
0 new messages