SECURECRT Automatic Login to server script and scripting simple instructions

Source: Internet
Author: User

http://blog.csdn.net/marising/article/details/6409196

Secure with SSH login server, if the server is more, landing once very troublesome, so, you can write VBScript to do it.

First, secure script introduction

Secure is a tutorial for VBScript scripts, VB scripts, please refer to the documentation.

Secure comes with the following objects:

The Application object, which is the CRT, is a top-level object, and all other content is derived from this object.

Session, conversation object, responsible for connection related

Tab object, which is the tab page

Scree object, which is responsible for interactive correlation, such as sending commands, receiving command returns, etc.

The main ones are the above, others look at the help document.

Second, the automatic landing instructions

1. Create session and connect to server

There are two ways, one is to set the parameter connection, one is to use the existing session settings to connect

Mode 1:

Crt.session.Connect ("protocol [email protected]")

Protocol: protocol, support Ssh,ssh2,telnet

User: Username

Host: Machine name

Mode 2:

Set conf = crt. Opensessionconfiguration ("Session_name")

Set tab = Conf. Connectintab ()

Session_name: It is the name of the session you set yourself, so the advantage is that you can use the set session to connect and simply.

2. Clone tab and login to server

Set newtab = tab. Clone ()

The advantage of cloning is no longer landing, directly clone already have.

3. Set the name of the tab, etc.

tab. Caption = xxx

More labels, one alias per setting required

4. Connect to the server

The connection function is mainly a variety of methods in the Screen object.

Set SCR = tab. Screen ' first gets tab screen

Scr. Send SSH Login command ("SSH" & Host & vbcr)

Scr. Waitforstring (host & ' s password: ") ' Prompt for password

Scr. Send (pwd & vbcr) ' Enter password

Third, complete examples

[VB]View Plaincopy
  1. # $language = "VBScript"
  2. # $interface = "1.0"
  3. Crt. screen.synchronous = True
  4. Function Login (Ptab,name,host,pwd,cmd)
  5. Dim TAB,SCR
  6. Set tab = Ptab. Clone ()
  7. tab. Caption = Name
  8. Set SCR = tab. screen
  9. Scr. Send ("SSH" & host & vbcr)
  10. Scr. Waitforstring (Host & "' s Password:")
  11. Scr. Send (pwd & vbcr)
  12. Scr. Send (cmd & vbcr)
  13. Set Login = Tab
  14. End Function
  15. Sub Main
  16. Dim Conf,tab
  17. Set conf = crt. Opensessionconfiguration ("Session_name")
  18. Set tab = Conf. Connectintab ()
  19. Set tab = Login (tab,"name1","[email protected]", "xxx","cd/home/")
  20. Set tab = Login (tab,"Name2","[email protected]", "xxx","shell cmd")
  21. End Sub

For a more detailed introduction, please refer to the SECURECRT Help file.

SECURECRT Automatic Login to server script and scripting simple instructions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.