LoginSignup
0
1

More than 1 year has passed since last update.

pythonでfortigateの設定を自動取得する

Posted at

前提条件

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)

で出力ができます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1