Search code examples
clojurepallet

How do I configure sshd_config


So I have an ubuntu vm with ssh set up. Pallet can ssh in, install packages and run scripts which is handy dandy; however, how do I configure my sshd_config using pallet?

pallet.crate.ssh-key has a nice function aptly named config that configures ~/.ssh/config. It takes a map and updates values in the file accordingly. Very nice but what do I use for sshd_config?

I see https://github.com/pallet/ssh-crate but it's not available on clojars and doesn't have a perfect config function equivalent. What do I use or am I not looking at ssh-crate correctly?


Solution

  • As of Nov 23 2014, the package is not available on clojars for whatever reason.

    Note: Pallet will check the md5 hash after the first write and will error if you try lifting again after manually making local changes. This can be worked around with remote-file with :content and :overwrite-changes true instead of using ssh-crate. See https://github.com/pallet/pallet/blob/develop/src/pallet/actions.clj#L398.

    To install: run $ git clone https://github.com/pallet/ssh-crate.git on the command line. $ cd ssh-crate and $ lein install.

    To use:

    Include the dependency in your project.clj:

    :dependencies [[com.palletops/ssh-crate "0.8.0-SNAPSHOT"]]
    

    In your somename.clj file:

    (ns my.namespace
      (:require [pallet.crate.ssh :as ssh]))
    
    (def sshd-config
      (ssh/server-spec
       {:sshd-config
        {"PasswordAuthentication" "no"
        "PermitRootLogin" "no"
        "AllowUsers" "myuser"
        "Protocol" 2
        "Port" 12345
        "IgnoreRhosts" "yes"
        "HostbasedAuthentication" "no"
        "PermitEmptyPasswords" "no"
        "LogLevel" "INFO"}}))
    

    Use pallet.api/lift on sshd-config to apply configuration.