前提条件
Fortigateはexec_commandではchannelが切れてしまうようで、
config vdom
edit XXXXX
に入れない
invoke_shell()を利用する
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('hostname', username='username', password='password')
channel = client.invoke_shell()
こんな感じ。
stdin = channel.makefile('w')
stdout = channel.makefile('r')
stdin.write('''
config vdom
edit XXXXX
show firewall policy
exit
''')
こうするとコマンドが流し込めます。
for l in stdout:
print(l)
で出力ができます。