1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

TeraTerm自動ログインマクロ

Posted at

ダイアログで選択したサーバに自動ログインするTeraTermマクロをメモ書きします。

サーバ選択.png

;===============================================
;; [[初期値設定]]

;; 接続先定義数
DEFINE_NUM = 2

;; 接続先種類定義
strdim TYPE_NAME DEFINE_NUM
TYPE_NAME[0] = '開発環境サーバ'
TYPE_NAME[1] = '検証環境サーバ'

;; サーバアドレス定義
strdim HOST_ADDRESS DEFINE_NUM
HOST_ADDRESS[0] = '192.168.1.X'
HOST_ADDRESS[1] = '192.168.1.Y'

;; ユーザ名定義
strdim USER_ID DEFINE_NUM
USER_ID[0] = 'userId1'
USER_ID[1] = 'userId2'

;; パスワード定義
strdim PASSWD DEFINE_NUM
PASSWD[0] = 'password1'
PASSWD[1] = 'password2'

;; 秘密鍵ファイルパス定義(フルパス)
strdim KEY_FILE DEFINE_NUM
KEY_FILE[0] = ''
KEY_FILE[1] = 'C:\Users\userId2\.ssh\id_rsa'

;; 選択接続先インデクス
SELECTED_INDEX = -1
;===============================================

;; 接続先種類選択
listbox '接続先を選択して下さい' '接続先選択' TYPE_NAME
if 0 <= result then
	SELECTED_INDEX = result
    ;;messagebox TYPE_NAME[SELECTED_INDEX] '選択された接続先'
else
    end
endif

;; 接続用コマンド組立て
COMMAND = HOST_ADDRESS[SELECTED_INDEX]
strconcat COMMAND ':22 /ssh /2'
strlen KEY_FILE[SELECTED_INDEX]
if 0 < result then
	strconcat COMMAND ' /auth=publickey'
	strconcat COMMAND ' /keyfile='
	strconcat COMMAND KEY_FILE[SELECTED_INDEX]
else
	strconcat COMMAND ' /auth=password'
endif
strconcat COMMAND ' /user='
strconcat COMMAND USER_ID[SELECTED_INDEX]
strconcat COMMAND ' /passwd='
strconcat COMMAND PASSWD[SELECTED_INDEX]
 
;; 接続コマンド実行
connect COMMAND
 
;; マクロ終了
end
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?