42
MC Technologies GmbH
2.
Additional functions
2.1
Router configuration through SSH and XML file
The router can be configured using the SSH protocol through the local Ethernet interface or in remote operation.
SSH or Secure Shell indicates both a network protocol and a corresponding program, using which an encrypted
network connection can be produced with 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 default settings of the router:
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.
Under Linux:
ssh [email protected] 'su -c "/usr/sbin/export_cfg"' > config.xml
or
ssh [email protected] 'su -c "/usr/sbin/export_cfg tgz"' > config.tgz
Under Windows with PLINK.EXE
plink -2 -pw admin [email protected] "su -c \"/usr/sbin/export_cfg\"" > config.xml
or
plink -2 -pw admin [email protected] "su -c \"/usr/sbin/export_cfg tgz\"" > config.tgz
2.1.2
Upload configuration via SSH
Under Linux:
a.
Without router-reboot:
cat config.xml | ssh [email protected] 'su -c "/usr/sbin/store_cfg"'
b.
With subsequent router reboot:
cat config.xml | ssh [email protected] 'su -c "/usr/sbin/store_cfg; /sbin/reboot"'
The password is requested interactively by SSH. An automatic batch operation is not possible. However,
the programs "sshpass" allows you 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 [email protected] 'su -c "/usr/sbin/store_cfg; /sbin/reboot"'
The Linux command is as follows:
sshpass -padmin ./cfgupl.sh
Under Windows with PSCP.EXE and PLINK.EXE
a.
Without router-reboot:
pscp -scp -pw admin config.xml [email protected]:/tmp/cfg.xml
plink -2 -pw admin [email protected] "su -c \"/usr/sbin/store_cfg /tmp/cfg.xml\""
b.
With subsequent router reboot:
pscp -scp -pw admin config.xml [email protected]:/tmp/cfg.xml
plink -2 -pw admin [email protected] "su -c \"/usr/sbin/store_cfg /tmp/cfg.xml; /sbin/reboot\""