Paramiko "invalid Command" When Trying Non-standard Command For Vyatta
I've just tried to connect my Python/Django app with Vyatta server using Paramiko for SSHing. Unfortunately, when I try to run show interfaces it throws 'Invalid command'. However,
Solution 1:
As mentioned earlier you can use vyatta-cfg-cmd-wrapper and set any configuration node:
<import stuff>
command = """
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper begin
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper set system host-name newhostname
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper commit
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper save
"""
sshobj = paramiko.SSHClient()
sshobj.set_missing_host_key_policy(paramiko.AutoAddPolicy())
sshobj.connect(IP,username=login,password=sshpass)
stdin,stdout,stderr=sshobj.exec_command(command)
print''.join(stdout)
sshobj.close()
And the reult as follow:
user@hostname$ python vyatta.py
Saving configuration to'/config/config.boot'...
Solution 2:
Vyatta commands are done by templates in vbash. There are a bunch of environment variables that need to be set in order for templates to work. You have to either use a remote envrionment that sources .profilerc or there is an undocumented script vyatta-cfg-command wrapper to setup more complex state necessary to commit changes.
Solution 3:
In my case, I solved the problem by using this command:
vbash -c -i "restart vpn"
Post a Comment for "Paramiko "invalid Command" When Trying Non-standard Command For Vyatta"