Renci.SshNet 라이브러리를 사용하여 Fortigate 장치에서 방화벽 구성을 업데이트하는 간단한 응용 프로그램을 만들었습니다.SSH.NET으로 실행되는 명령에 하위 명령 제공
var auth =
new AuthenticationMethod[] { new PasswordAuthenticationMethod(username, password) };
ConnectionInfo ConnNfo = new ConnectionInfo(server, 22, username, auth);
sshclient.Connect();
string command;
string addressname = "testaddress";
command = "config firewall address";
output.Add(command);
output.Add(sshclient.CreateCommand(command).Execute());
command = string.Format(@"edit {0}", addressName);
output.Add(command);
output.Add(sshclient.CreateCommand(command).Execute());
sshclient.Disconnect();
본인은 출력에서 다음을 얻을 :
config firewall address
fw1 # fw1 (address) #
edit testaddress
fw1 # Unknown action 0 fw1 #
같은 명령이 정상 SSH 연결을 통해 잘 작동합니다.
fw1 # config firewall address
fw1 (address) # edit testaddress
new entry 'testaddress' added
fw1 (testaddress) #
정확히 내가 올바르게 사용하고 있는지 궁금한 경우 입니다.