LoginSignup
3
3

More than 5 years have passed since last update.

自動ログイン ( teraterm macro )

Last updated at Posted at 2014-02-05

メモ

host.login.ttl
username  = ''               ; ssh user
userpass  = ''               ; ssh user password
publickey = '~/.ssl/pub.key' ; ssh public key file
hostname  = '127.0.0.1:22'   ; ssh host:port
port      = '22'             ; ssh host connection port
auth_type = 1                           ; ssh auty type
; auth_type = 1 : password
; auth_type = 2 : public key
; auth_type = 3 : challenge
; auth_type = 4 : pageant 
;

getspecialfolder logdir "MyDocuments";
logfileptn = '%s_%s-%s.log'

getdate datetime  '%Y%m%d'
getdate datetime2 '%Y%m%d-%H%M%S'

sprintf logfileptn username hostname2 datetime2;
logfile=inputstr;

debugmode = 0;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


sshuser = ' /user=';
strconcat sshuser username;

sshpass = ' /passwd=';
strconcat sshpass userpass;

sshpkey = ' /keyfile=';
strconcat sshpkey publickey;

msg = '';

strconcat msg hostname ; xample.com

if auth_type=1 then; password
   sshauth   = ' /ssh /2 /auth=password ';

   sprintf '%s %s %s %s' hostname sshauth sshuser sshpass
   msg=inputstr;

elseif auth_type=2 then; publickey
   sshauth   = ' /ssh /2 /auth=publickey ';

   sprintf '%s %s %s %s %s' hostname sshauth sshuser sshpass sshpkey
   msg=inputstr;

elseif auth_type=3 then; challenge
   sshauth   = ' /ssh /2 /auth=challenge';

   sprintf '%s %s %s %s' hostname sshauth sshuser sshpass
   msg=inputstr;

elseif auth_type=4 then; pagent
   sshauth   = ' /ssh /2 /auth=pagent';

   sprintf '%s %s %s %s' hostname sshauth sshuser
   msg=inputstr;

endif;

connect msg;


changedir logdir;
; binary:appended:plain:timestamp:dialog 
logautoclosemode 1;
logopen logfile 0 1 1 0 0;

logwrite #13#10;
logwrite '***********************************************'
logwrite #13#10;
logwrite 'login : '
logwrite datetime2
logwrite #13#10;
logwrite '-----------------------------------------------'
logwrite #13#10;

if debugmode=1 then

   wait '#' '$'
   sendln 'id'
   pause 1;

   wait '#' '$'
   sendln 'date'
   pause 1;

   wait '#' '$'
   sendln '/sbin/ifconfig'
   pause 1;

   wait '#' '$'
   send 'ps aux '
   send '| sed -e "s/[ ]\+/ /ig"'
   send '| cut -d " " -f 11'
   send '| grep "/"'
   send '| grep "[[]" -v'
   send '| sort'
   send '| uniq'
   sendln
   pause 1;

   wait '#' '$'
   send 'netstat -an'
   send '| cut -d ":" -f 2'
   send '| cut -d " " -f 1'
   send '| sed -e "/^$/d"'
   send '| sed "/[^0-9]/d"'
   send '| sort'
   send '| uniq'
   sendln
   pause 1;

   wait '#' '$'
   sendln 'df -H'
   pause 1;

endif;

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