2016-04-26 4 views
0

私はこのプロジェクトの支援が必要です。Python - JunOSでユーザーのパスワードを変更します。

私はこのジュニパールータを問題なく変更することができます。ユーザーのパスワードを変更する必要があるときに問題が発生します。

画面または出力の下に... 私は試みました: ユーザーがパスワードを変更するコマンドを送信しました。次に、CLIから新しいパスワードを入力するように求められます。これは、passwd1と2の文字列を入力して入力しようとしています。私も(GETPASSで出力を隠ししようとした)が、何も...それはそれはスキップされますパスワードを入力することができないので、その後、空転していないと期待しに行く:

screenshot

答えて

-1

implimentingの別の方法がありますそれ:

​​

出力: -のpythonを使用してのJunosデバイスを処理するための

Password: 
Password: 
set system login user Vijay class read-only authentication encrypted-password $1$siC6W8.B$8FeEjf/Nt7shR1e8Axl.v1 

、私はPyEZを使用するためにあなたをお勧めします

例:

from jnpr.junos import Device 
from lxml import etree 

dev = Device('hostname', user='username', password='Password123') 
dev.open() 

cnf = dev.rpc.get_config() # similar to 'show configuration | no-more' on cli 
print (etree.tounicode(cnf)) 

dev.close() 
0

これ解像度はインタラクティブCLIのプロンプトを設定することです。たとえば、 "="のようなサポートされていないプロンプト "対話型プロンプト"が必要であることがわかっている場合は、Pythonにあなたのコマンドを送信してプロンプトをリセットするよう指示する必要があります。

例:

def JunOS(self,host_ips,config,commit):                                

      try:                                       
        conn = SSH2(verify_fingerprint = False)                            
        conn.connect(host_ips)                                 
        print "Connecting to : ", host_ips                              
        conn.login(account)                                 
        print "**********************"                               
        conn.execute(config)                                 
        print conn.response                                 
        conn.set_prompt(r'.$')                                 
        conn.execute('set system login user admin authen plain')                        
        conn.execute(psswd)                                 
        conn.set_prompt()                                  
        conn.execute(psswd)                                 
        conn.execute(commit)                                 
        print conn.response                                 
        time.sleep(3)                                   
        print "********************************"                            
        print "Password Updated !"                                
        print "********************************"                            
      except:                                      
        print "IP for this device : ", host_ips                            
        print "Unable to connect or Username/password are incorrect"                       
        print "**********************" 
        time.sleep(2) 
関連する問題