0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

デスクトップ小技 Teraterm ログイン編

Posted at

Teratermの利用時に有用な小技をいくつかまとめます。

Teratermマクロを使ったログイン

Teraterm用にログイン情報をマクロファイル(.ttl)に設定しておくことで、毎回のサーバー接続時の作業 (ターミナルの起動→接続先(アドレス/ポート)の入力→接続IDの指定, パスワードの入力またはキーファイルの指定)がマクロの実行だけで済みます。

ログイン操作は、connectを使用します。
connect [アドレス]:[ポート] /ssh /auth=(publickey|password)/user=userid (/passwd=パスワード, /keyfile=.pemファイル名)

Teratermマクロに記載する例

キーファイル(.pem)でのログイン
connect ec2-11-22-33-44.ap-northeast-1.compute.amazonaws.com:22 /ssh /2 /auth=publickey /user=ec2-user/keyfile=C:\work\keyfile\ec2-key.pem
パスワードでのログイン
connect '22.33.44.55:22 /ssh /auth=password /user=test-user /passwd=password'

マクロファイル(.ttl)の関連付け

.ttlファイルをTeratermマクロttpmacro.exeと関連付けすることで、.ttlファイルをダブルクリックするだけでログインできます。
プログラムから開く> 別のプログラムを選択 > アプリを選択して.ttlファイルを開く > PCでアプリを選択する を選択後、ttpmacro.exeを選択します。

スクリーンショット 2024-10-04 102224.png

Teraterm設定内容の保管

Teratermの設定はメニューから変更できますが、変更内容は Teratermを終了すると消えてしまいます。
Teraterm終了後も変更内容を継続して利用する場合は、変更をTeraterm.iniファイルに保存できます。

Teratermのメニューから、

Teraterm起動時 iniファイルの指定

次回起動時に、このファイルが読み込まれることで、ファイル保管時の変更(例えばフォント、色/背景色、ウインドウのサイズや接続席の履歴等)を、利用することができます。

INIファイルの指定を追加
connect '22.33.44.55:22 /ssh /auth=password /user=test-user /passwd=password' /F=C:\Teraterm\teraterm.ini 

ログイン後のキー入力

プロンプト表示後のSSHコマンド打鍵例
connect '22.33.44.55:22 /ssh /auth=password /user=test-user /passwd=password' /F=C:\Teraterm\teraterm.ini 

if result <> 2 then
    messagebox 'It could not be connected.' 'Connected error'
    end
endif

;; 10秒以内にプロンプトが表示されない場合終了
timeout = 10
wait '$' '#'
if result = 0 then
    disconnect
    end
endif

;; backservにtestuserでSSH接続
sendln 'ssh testuser@backserv'
;; 「password:」が表示されたらパスワードを入力
wait 'password:'
sendln 'hogehoge'
wait '$' '#'

内容はTERATERMマクロのファイル(.ttl)として保管。

拡張子をttpmacro.exeに関連付け

teratermマクロの実行時は、ttpmacro.exe [マクロファイル].ttl で実行できますが、この拡張子.ttl をttpmacro.exeと関連付けしておくことで、ファイルのダブルクリックでログインできるようになります。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?