MC Technologies GmbH
44
2. 2. Additional functions
2.1 Router configuration using SSH and XML file
The router can be configured using the SSH protocol via the local Ethernet interface or in remote operation.
SSH or Secure Shell refers to both a network protocol and a corresponding programme which allows an encrypted net-
work connection to be generated using a remote device.
In
Linux
, use console input. In
Windows
, we recommend using the programs
plink.exe
and
pscp.exe
, which can
be downloaded at putty.org.
The examples below are based on the router default settings:
Username:
admin
Password:
admin
Router IP-Address:
192.168.0.1
2.1.1 Download configuration via SSH
You can download the router configuration as an XML file or as a TGZ file.
For Linux:
ssh admin@192.168.0.1 'su -c "/usr/sbin/export_cfg"' > config.xml
oder
ssh admin@192.168.0.1 'su -c "/usr/sbin/export_cfg tgz"' > config.tgz
For Windows with PLINK.EXE
plink -2 -pw admin admin@192.168.0.1 "su -c \"/usr/sbin/export_cfg\"" > config.xml
oder
plink -2 -pw admin admin@192.168.0.1 "su -c \"/usr/sbin/export_cfg tgz\"" > config.tgz
2.1.2 Upload configuration via SSH
For Linux:
a.
a.
Without router reboot:
cat config.xml | ssh admin@192.168.0.1 'su -c "/usr/sbin/store_cfg"'
b.
b.
With subsequent router reboot:
cat config.xml | ssh admin@192.168.0.1 'su -c "/usr/sbin/store_cfg; /sbin/reboot"'
The password is requested interactively by SSH. An automatic batch operation is not possible. You can, however, use
the "sshpass" programme to run a script file comprising the password. The script file (for example, cfgupl.sh) must
contain the following:
#!/bin/bash cat config.xml | ssh admin@192.168.0.1 'su -c "/usr/sbin/store_cfg; /sbin/reboot"'
The Linux command is as follows:
sshpass -padmin ./cfgupl.sh
For Windows with PSCP.EXE and PLINK.EXE
a.
Without router-reboot:
pscp -scp -pw admin config.xml admin@192.168.0.1:/tmp/cfg.xml
plink -2 -pw admin admin@192.168.0.1 "su -c \"/usr/sbin/store_cfg /tmp/cfg.xml\""
b.
With subsequent router reboot:
pscp -scp -pw admin config.xml admin@192.168.0.1:/tmp/cfg.xml
plink -2 -pw admin admin@192.168.0.1 "su -c \"/usr/sbin/store_cfg /tmp/cfg.xml; /sbin/reboot\""