前提・実現したいこと
TeraTermマクロを利用し、Azureにログインしようとしているのですが、
接続ができない状態です。
TeraTermに詳しい方、ご教示よろしくお願いいたします。
発生している問題・エラーメッセージ
connectを実行した際に、「result」の内容を確認すると、
1 (ホストへの接続はされていないが、Tera Term へのリンクはされている。)
が格納されている状態です。
該当のソースコード
TeraTermMacro
1;========================================================================= 2; 使用変数 3;========================================================================= 4username = '' 5portnum = '50500' 6pattern = '^([\w-]+)' 7size = 0 8 9folderpath = '.\'' 10foldername = 'passdir' 11passwdfile = 'passwd_' 12 13logfoldername = 'log' 14logfullpath = '' 15logfilename = 'log_' 16 17 18 19;========================================================================= 20; 接続先ホスト指定(変更箇所) 21;========================================================================= 22hostname = '接続先のアドレス' 23 24;========================================================================= 25; パスワード情報保管先作成 26;========================================================================= 27filestat foldername size 28if result == -1 then 29 foldercreate foldername 30endif 31 32;========================================================================= 33; パスワード情報ファイル名・格納先文字列作成 34;========================================================================= 35strmatch hostname pattern 36strconcat passwdfile matchstr 37strconcat passwdfile '.dat' 38 39strconcat folderpath foldername 40strconcat folderpath '\' 41strconcat folderpath passwdfile 42 43;========================================================================= 44; ログ保管先作成 45;========================================================================= 46getdir logfullpath 47 48strconcat logfullpath '\' 49strconcat logfullpath logfoldername 50 51filestat logfullpath size 52if result == -1 then 53 foldercreate logfullpath 54endif 55 56strconcat logfullpath '\' 57strconcat logfullpath matchstr 58 59filestat logfullpath size 60if result == -1 then 61 foldercreate logfullpath 62endif 63 64;========================================================================= 65; ログイン処理 66;========================================================================= 67inputbox 'Login Username:' 'Enter Username' 68 69strlen inputstr 70 71if result <= 0 then 72 messagebox 'ユーザ名が確認できなかったため、処理を終了します。' 'ログイン操作中止' 73 end 74endif 75 76strconcat username inputstr 77 78getpassword folderpath username userpasswd 79 80filenamebox '公開鍵の選択' 0 'C:\' 81strconcat keyfilepath inputstr 82 83msg = hostname 84strconcat msg ':' 85strconcat msg portnum 86strconcat msg ' /ssh /2 /auth=publickey /user=' 87strconcat msg username 88strconcat msg ' /passwd=' 89strconcat msg userpasswd 90strconcat msg ' /keyfile=' 91strconcat msg keyfilepath 92 93messagebox msg 'connection setting' 94 95connect msg 96 97if result <> 2 then 98 messagebox result 'Result' 99 messagebox 'It could not be connected.' 'Connection Error' 100 end 101endif 102 103timeout = 10 104wait '$' '#' 105if result = 0 then 106 disconnect 107 end 108endif 109 110;========================================================================= 111; ログ作成処理 112;========================================================================= 113getdate datestr '%Y%m%d' 114gettime timestr '%H%M%S' 115 116strconcat logfilename hostname 117strconcat logfilename '_' 118 119strconcat logfilename datestr 120strconcat logfilename timestr 121strconcat logfilename '_' 122 123strconcat logfilename username 124strconcat logfilename '.log' 125 126messagebox logfullpath 'logfullpath' 127 128changedir logfullpath 129logopen logfilename 0 1 0 1
(2019年8月25日 追記)
コードを簡略化しました。
TeraTermMacro
1username = '(ユーザ名)' 2password = '(パスワード)' 3hostname = '(ホスト名 or IPアドレス)' 4keyfile = '(秘密鍵指定)' 5 6msg = hostname 7strconcat msg ':22 /ssh /auth=publickey /user=' 8strconcat msg username 9strconcat msg ' /keyfile=' 10strconcat msg keyfile 11strconcat msg ' /passwd=' 12strconcat msg password 13connect msg 14 15if result <> 2 then 16 messagebox result 'Result' 17 messagebox 'It could not be connected.' 'Connection Error' 18 end 19endif 20 21timeout = 10 22wait '$' '#' 23if result = 0 then 24 disconnect 25 end 26endif
試したこと
・ポート番号を「22」に戻して実施 → 同様のエラー
・「msg」の順序変更(/user や /keyfile の位置を変更) → 同様のエラー
・このマクロを使用せずに、TeraTermでAzureのIPアドレス(ホスト名)を指定 → ログイン可能
・このマクロを使用し、自宅サーバへのログイン → ログイン可能
補足情報(FW/ツールのバージョンなど)
TeraTermバージョン:
Version 4.103(SVN# 7769)
Macro作成エディタ:
Sakura Editor 2.2.0.1
マクロを使用しているマシン情報:
OS 名: Microsoft Windows 10 Pro
OS バージョン: 10.0.18362 N/A ビルド 18362
OS 製造元: Microsoft Corporation
OS 構成: スタンドアロン ワークステーション
OS ビルドの種類: Multiprocessor Free
最初のインストール日付: 2019/06/30, 21:00:45
システム起動時間: 2019/07/18, 19:44:48
システムの種類: x64-based PC
プロセッサ: 1 プロセッサインストール済みです。
[01]: Intel64 Family 6 Model 26 Stepping 5 GenuineIntel ~2793 Mhz
BIOS バージョン: Phoenix Technologies, LTD 6.00 PG, 2009/03/19
Windows ディレクトリ: C:\WINDOWS
システム ディレクトリ: C:\WINDOWS\system32
起動デバイス: \Device\HarddiskVolume1
システム ロケール: ja;日本語
入力ロケール: ja;日本語
タイム ゾーン: (UTC+09:00) 大阪、札幌、東京
物理メモリの合計: 16,375 MB
利用できる物理メモリ: 6,791 MB
仮想メモリ: 最大サイズ: 16,375 MB
仮想メモリ: 利用可能: 2,582 MB
仮想メモリ: 使用中: 13,793 MB
ページ ファイルの場所: N/A
ドメイン: WORKGROUP

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/11/24 06:13
退会済みユーザー
2019/11/24 06:46
2019/11/25 05:36
退会済みユーザー
2019/11/25 06:30