Upload config to juniper

Hey guys,

Do any of you have any idea if it's possible to upload configuration from a
script (prefix-list updates in this case) to a JunOS device (MX)?
For Cisco devices I'm doing it using rcp.

Thanks,
Florin

I do this with pyexpect for blacklist updating. It works amazingly well.

One thing to remember when communicating with the JunOS device is that
if you fail to disable the CLI controls, communicating with the device
is very difficult.

I do something like:

  import pexpect
  child = pexpect.spawn ('ssh',
['-p','22','-o','StrictHostKeyChecking=no',"router ip address goes
here"], 2)

  child.sendline("set cli screen-length 0")
  child.sendline("set cli screen-width 0")

  < put your commands here to talk to the router >

-j

You'll need to setup SSH keys in advance to do so without an
additional password for the device to download the script.

Alternatively... SCP the file to a temporary file on the device then
"load merge" the uploaded file, to merge config from the script.

Net::SSH::Expect from CPAN to connect via ssh from perl.

Something like
use Net::SSH::Perl;
use Net::SSH::Expect;

my $ssh = Net::SSH::Expect->new( host =>
'myfavoritehostname.example.com', user => 'blahblahblah', password =>
'1234', raw_pty => 1);
$ssh->login(q[blahblah@myfavoritehostname.example.com's password]);
$output1 = $ssh->exec("configure private");
# $blah = $ssh->exec("load merge
username@scriptserver.example.com:/path/to/scriptfile_to_load.txt");
print scalar $ssh->exec("show | compare");
# commit

Actually if you use the JUNOS api and the reference scripts there are
examples to do just this.

I use the Netconf API and send xml config snippets like so:

<configuration>
<security>
  <zones>
   <security-zone>
    <name>Untrust</name>
     <address-book>
      <address operation="delete">
       <name>auto_ip-7</name>
       <ip-prefix>67.23.7.115/32</ip-prefix>
      </address>
      <address-set>
       <name>demo_inbound_permit</name>
       <address operation="delete">
       <name>auto_ip-7</name>
       </address>
      </address-set>
     </address-book>
   </security-zone>
  </zones>
</security>
</configuration>