rset(1) : Formulas

Juniper Switches and Routers

Juniper Networks develops switches and routers with very flexible management capabilities:

  1. Full-featured Unix userland (FreeBSD)
  2. Standard shell for root login
  3. A CLI which accept input as arguments or from a pipe

Configure SSH

Enabling root login provides access to the Unix shell over SSH, which will allow us to use rset(1) to configure the switch

set system root-authentication ssh-ed25519 "ssh-ed25519 key..."
set system services ssh root-login deny-password

Now that we have SSH access to the Junos OS/FreeBSD userland we can add a route entry

# routes.pln
192.168.0.7: juniper/
   ex2300-c.pln

Change the default connecting user to root

# ssh_config
Host 192.168.0.7
  ConnectTimeout=10
  User root

Inline Commands

Run individual commands inline

date:
   cli set date ntp 162.159.200.23

Configure Mode

The Juniper cli tool accepts multi-line commands, and is able to load configuration from a file

# ex2300-c.pln
interfaces:
   cli <<-!!
   configure
   load set juniper/ex2300-c
   show | compare
   ${COMMIT:-commit}
   !!

In this example, an environment variable can be set to override commit

rset -E 'COMMIT="rollback"' 192.168.0.8