忍者ブログ

◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…?

LinuC(Linux技術者認定資格)&リナックスサーバ構築設定事例

   

[PR]

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

【mailコマンド】の使用例

[root]# mail←未読メールを読む場合
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/root": 5 messages 5 new
>N  1 root@reverie.example  Fri Oct 15 23:42  19/819   "Anacron job 'cron.daily'"
 N  2 root@reverie.example  Tue Oct 19 22:30  56/1735  "LogWatch for reverie.example.com"
 N  3 root@reverie.example  Tue Oct 19 22:31  19/821   "Anacron job 'cron.daily'"
 N  4 root@reverie.example  Mon Nov  1 14:52  19/818   "Anacron job 'cron.daily'"
 N  5 root@dgx.example.com  Wed Nov  3 15:29  19/796   "Anacron job 'cron.daily'"
& t1←メールを選択
Message 1:
From root@reverie.example.com  Fri Oct 15 23:42:19 2010
Date: Fri, 15 Oct 2010 23:42:18 +0900
From: root@reverie.example.com (Anacron)
To: root@reverie.example.com
Subject: Anacron job 'cron.daily'

/etc/cron.daily/tripwire-check:
****    Error: Tripwire database for reverie.example.com not found.    ****
**** Run /etc/tripwire/twinstall.sh and/or tripwire --init. ****

[root]# ls -al mbox
-rw-------    1 root     root         5044 11月  3 15:38 mbox

[root]# mail -f←既読メールを読む場合

[root]# mail -s test-mail reverie@example.com←メールを作成して送る
TEST MAIL.
.
Cc:

[root]# tail /var/log/maillog←メールのログ確認
Nov  3 15:43:11 reverie sendmail[1764]: oA36hBj5001764: from=root, size=55, class=0, nrcpts=1, msgid=<201011030643.oA36hBj5001764@reverie.example.com>, relay=root@localhost
Nov  3 15:43:11 reverie sendmail[1766]: oA36hB0K001766: from=<root@reverie.example.com>, size=346, class=0, nrcpts=1, msgid=<201011030643.oA36hBj5001764@reverie.example.com>, proto=ESMTP, daemon=Daemon0, relay=localhost.localdomain [127.0.0.1]
Nov  3 15:43:11 reverie sendmail[1764]: oA36hBj5001764: to=reverie@example.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30044, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (oA36hB0K001766 Message accepted for delivery)
Nov  3 15:43:11 reverie sendmail[1767]: oA36hB0K001766: to=<reverie@example.com>, ctladdr=<root@reverie.example.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=pmlocal, pri=30549, dsn=2.0.0, stat=Sent

PR

【pop3有効化】の設定メモ

[root]# vi /etc/xinetd.d/ipop3
#       disable                 = yes←無効設定をコメント化する

[root]# /etc/rc.d/init.d/xinetd restart
xinetdを停止中:                                            [  OK  ]
xinetdを起動中:                                            [  OK  ]

[root]# tail /var/log/messages
Nov  3 14:26:48 reverie 11月  3 14:26:48 su(pam_unix)[1330]: session opened for user root by reverie(uid=500)
Nov  3 14:29:03 reverie 11月  3 14:29:03 su(pam_unix)[1330]: session closed for user root
Nov  3 14:29:04 reverie sshd(pam_unix)[1300]: session closed for user reverie
Nov  3 15:15:23 reverie sshd(pam_unix)[1396]: session opened for user reverie by (uid=500)
Nov  3 15:15:29 reverie 11月  3 15:15:29 su(pam_unix)[1426]: session opened for user root by reverie(uid=500)
Nov  3 15:21:45 reverie xinetd[1060]: Exiting...
Nov  3 15:21:45 reverie 11月  3 15:21:45 xinetd: xinetd停止 succeeded
Nov  3 15:21:46 reverie xinetd[1483]: xinetd Version 2.3.11 started with libwrap loadavg options compiled in.
Nov  3 15:21:46 reverie xinetd[1483]: Started working: 2 available services
Nov  3 15:21:48 reverie xinetd: ・ 鰯ucceeded

【sendmail】設定メモ

[root]# tar -xvzf CF-3.7Wpl2.tar.gz←「CF-3.7Wpl2.tar.gz」を用意しておき解凍する
[root]# cd CF-3.7Wpl2
[root]# cp -p Standards/sendmail-v8.def sendmail.def

[root]# vi sendmail.def
■編集内容は環境により任意に記述■

[root]# pwd
/usr/local/src/CF-3.7Wpl2

[root]# make sendmail.cf
MASTERDIR=./Master TOOLDIR=./Tools \
./Tools/Configure sendmail.def > sendmail.cf.tmp
mv -f sendmail.cf.tmp sendmail.cf

[root]# vi sendmail.cf
■下記のように編集↓■
#O AutoRebuildAliases=False 
←【 # を入れてコメント化】

[root]# cp -p /etc/mail/sendmail.cf /etc/mail/sendmail.cf.original
[root]# cp -p sendmail.cf /etc/mail
cp: `/etc/mail/sendmail.cf' を上書きしてもよろしいですか(yes/no)? y
[root]# echo $?
0 ←正常終了を確認

[root]# vi /etc/mail/sendmail.localip
■下記のように編集↓■
ネットワークアドレス記入

[root]# vi /etc/mail/sendmail.localdomain
■下記のように編集↓■
ドメイン名の記入

[root]# vi /etc/mail/sendmail.relay.to
■下記のように編集↓■
ドメイン名の記入

[root]# ls -al /etc/aliases*
-rw-r--r-- 1 root root 1343 2月 25 2003 /etc/aliases
-rw-r----- 1 smmsp smmsp 12288 11月 1 13:45 /etc/aliases.db
[root]# chown root /etc/aliases.db
[root]# ls -al /etc/aliases*
-rw-r--r-- 1 root root 1343 2月 25 2003 /etc/aliases
-rw-r----- 1 root smmsp 12288 11月 1 13:45 /etc/aliases.db


[root]# /etc/rc.d/init.d/sendmail restart
sendmailを停止中: [ OK ]
sm-clientを停止中: [ OK ]
sendmailを起動中: [ OK ]
sm-clientを起動中: [ OK ]

[root]# tail /var/log/messages
Nov 1 14:51:30 reverie syslogd 1.4.1: restart.
Nov 1 16:04:56 reverie sshd(pam_unix)[7776]: session opened for user reverie by (uid=500)
Nov 1 16:04:58 reverie 11月 1 16:04:58 su(pam_unix)[7806]: session opened for user root by reverie(uid=500)
Nov 1 16:38:53 reverie 11月 1 16:38:53 sendmail: sendmail停止 succeeded
Nov 1 16:38:53 reverie 11月 1 16:38:53 sendmail: sm-client停止 succeeded
Nov 1 16:38:53 reverie 11月 1 16:38:53 sendmail: sendmail起動 succeeded
Nov 1 16:38:53 reverie 11月 1 16:38:53 sendmail: sm-client起動 succeeded

[root]# tail /var/log/maillog
Nov 1 16:38:53 reverie sendmail[7941]: alias database /etc/aliases rebuilt by reverie
Nov 1 16:38:53 reverie sendmail[7941]: /etc/aliases: 63 aliases, longest 10 bytes, 625 bytes total
Nov 1 16:38:53 reverie sendmail[7953]: starting daemon (8.12.8): SMTP+queueing@01:00:00
Nov 1 16:38:53 reverie sm-msp-queue[7962]: starting daemon (8.12.8): queueing@01:00:00

[root]# vi /etc/mail/sendmail.spamlist
■下記のように編集↓■
ホスト名@ドメイン名 # コメント記述
[root]# makemap hash /etc/mail/sendmail.spamlist.db < /etc/mail/sendmail.spamlist
[root]# echo $?
0 ←正常終了を確認

【自動起動(chkconfig)】の設定メモ

・例えば、namedを自動起動する場合

[root]# /sbin/chkconfig --list named
named           0:オフ  1:オフ  2:オフ  3:オフ  4:オフ  5:オフ  6:オフ

[root]# /sbin/chkconfig --level 35 named on ←ランレベル3、5で自動起動

[root]# /sbin/chkconfig --list named
named           0:オフ  1:オフ  2:オフ  3:オン  4:オフ  5:オン  6:オフ

【DNS動作確認】メモ

[root]# nslookup
Note:  nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead.  Run nslookup with
the `-sil[ent]' option to prevent this message from appearing.
> reverie
Server:         192.168.0.99
Address:        192.168.0.99#53

Name:   reverie.example.com
Address: 192.168.0.99
> reverie.example.com
Server:         192.168.0.99
Address:        192.168.0.99#53

Name:   reverie.example.com
Address: 192.168.0.99
> www
Server:         192.168.0.99
Address:        192.168.0.99#53

www.example.com canonical name = reverie.example.com.
Name:   reverie.example.com
Address: 192.168.0.99
> www.example.com
Server:         192.168.0.99
Address:        192.168.0.99#53

www.example.com canonical name = reverie.example.com.
Name:   reverie.example.com
Address: 192.168.0.99
> mail
Server:         192.168.0.99
Address:        192.168.0.99#53

mail.example.com        canonical name = reverie.example.com.
Name:   reverie.example.com
Address: 192.168.0.99
> mail.example.com
Server:         192.168.0.99
Address:        192.168.0.99#53

mail.example.com        canonical name = reverie.example.com.
Name:   reverie.example.com
Address: 192.168.0.99
> ftp
Server:         192.168.0.99
Address:        192.168.0.99#53

ftp.example.com canonical name = reverie.example.com.
Name:   reverie.example.com
Address: 192.168.0.99
> ftp.example.com
Server:         192.168.0.99
Address:        192.168.0.99#53

ftp.example.com canonical name = reverie.example.com.
Name:   reverie.example.com
Address: 192.168.0.99
> 192.168.0.99
Server:         192.168.0.99
Address:        192.168.0.99#53

99.0.168.192.in-addr.arpa       name = reverie.example.com.
> example.com
Server:         192.168.0.99
Address:        192.168.0.99#53

Name:   example.com
Address: 192.168.0.0
> www.yahoo.co.jp
Server:         192.168.0.99
Address:        192.168.0.99#53

Non-authoritative answer:
www.yahoo.co.jp canonical name = www.ya.gl.yahoo.co.jp.
Name:  
www.ya.gl.yahoo.co.jp
Address: 203.216.247.249
> set type=MX
> example.com
Server:         192.168.0.99
Address:        192.168.0.99#53

example.com     mail exchanger = 10 reverie.example.com.
> set type=AXFR
> example.com
Server:         192.168.0.99
Address:        192.168.0.99#53

example.com
        origin = reverie.example.com
        mail addr = postmaster.example.com
        serial = 2010101901
        refresh = 10800
        retry = 3600
        expire = 604800
        minimum = 86400
example.com     mail exchanger = 10 reverie.example.com.
example.com     nameserver = reverie.example.com.
Name:   example.com
Address: 192.168.0.0
ftp.example.com canonical name = reverie.example.com.
Name:   localhost.example.com
Address: 127.0.0.1
mail.example.com        canonical name = reverie.example.com.
Name:   reverie.example.com
Address: 192.168.0.99
www.example.com canonical name = reverie.example.com.
example.com
        origin = reverie.example.com
        mail addr = postmaster.example.com
        serial = 2010101901
        refresh = 10800
        retry = 3600
        expire = 604800
        minimum = 86400
> exit
[root]# dig reverie.example.com
; <<>> DiG 9.2.1 <<>> reverie.example.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16532
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;reverie.example.com.           IN      A

;; ANSWER SECTION:
reverie.example.com.    86400   IN      A       192.168.0.99

;; AUTHORITY SECTION:
example.com.            86400   IN      NS      reverie.example.com.

;; Query time: 1 msec
;; SERVER: 192.168.0.99#53(192.168.0.99)
;; WHEN: Tue Oct 19 22:28:16 2010
;; MSG SIZE  rcvd: 67

[root]# dig -x 192.168.0.99
; <<>> DiG 9.2.1 <<>> -x 192.168.0.99
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44119
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;99.0.168.192.in-addr.arpa.     IN      PTR

;; ANSWER SECTION:
99.0.168.192.in-addr.arpa. 86400 IN     PTR     reverie.example.com.

;; AUTHORITY SECTION:
0.168.192.in-addr.arpa. 86400   IN      NS      reverie.example.com.

;; ADDITIONAL SECTION:
reverie.example.com.    86400   IN      A       192.168.0.99

;; Query time: 1 msec
;; SERVER: 192.168.0.99#53(192.168.0.99)
;; WHEN: Tue Oct 19 22:28:48 2010
;; MSG SIZE  rcvd: 106

[root]# dig example.com mx
; <<>> DiG 9.2.1 <<>> example.com mx
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65275
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;example.com.                   IN      MX

;; ANSWER SECTION:
example.com.            86400   IN      MX      10 reverie.example.com.

;; AUTHORITY SECTION:
example.com.            86400   IN      NS      reverie.example.com.

;; ADDITIONAL SECTION:
reverie.example.com.    86400   IN      A       192.168.0.99

;; Query time: 0 msec
;; SERVER: 192.168.0.99#53(192.168.0.99)
;; WHEN: Tue Oct 19 22:30:27 2010
;; MSG SIZE  rcvd: 83

[root]# dig example.com axfr
; <<>> DiG 9.2.1 <<>> example.com axfr
;; global options:  printcmd
example.com.            86400   IN      SOA     reverie.example.com. postmaster.example.com. 2010101901 10800 3600 604800 86400
example.com.            86400   IN      MX      10 reverie.example.com.
example.com.            86400   IN      NS      reverie.example.com.
example.com.            86400   IN      A       192.168.0.0
ftp.example.com.        86400   IN      CNAME   reverie.example.com.
localhost.example.com.  86400   IN      A       127.0.0.1
mail.example.com.       86400   IN      CNAME   reverie.example.com.
reverie.example.com.    86400   IN      A       192.168.0.99
www.example.com.        86400   IN      CNAME   reverie.example.com.
example.com.            86400   IN      SOA     reverie.example.com. postmaster.example.com. 2010101901 10800 3600 604800 86400
;; Query time: 0 msec
;; SERVER: 192.168.0.99#53(192.168.0.99)
;; WHEN: Tue Oct 19 22:30:35 2010
;; XFR size: 11 records

[root]# tail /var/log/messages
Oct 19 22:17:37 reverie named[1455]: no IPv6 interfaces found
Oct 19 22:17:37 reverie named[1455]: listening on IPv4 interface lo, 127.0.0.1#53
Oct 19 22:17:37 reverie named[1455]: listening on IPv4 interface eth0, 192.168.0.99#53
Oct 19 22:17:37 reverie named[1455]: command channel listening on 127.0.0.1#953
Oct 19 22:17:37 reverie named[1455]: zone 0.0.127.in-addr.arpa/IN: loaded serial 2010101901
Oct 19 22:17:37 reverie named[1455]: zone 0.168.192.in-addr.arpa/IN: loaded serial 2010101901
Oct 19 22:17:37 reverie named[1455]: zone example.com/IN: loaded serial 2010101901
Oct 19 22:17:37 reverie named[1455]: running
Oct 19 22:26:26 reverie named[1455]: client 192.168.0.99#32772: transfer of 'example.com/IN': AXFR started
Oct 19 22:30:35 reverie named[1455]: client 192.168.0.99#32773: transfer of 'example.com/IN': AXFR started

[root]# dig example.com hinfo
; <<>> DiG 9.2.1 <<>> example.com hinfo
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40241
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;example.com.                   IN      HINFO

;; AUTHORITY SECTION:
example.com.            86400   IN      SOA     reverie.example.com. postmaster.example.com. 2010101901 10800 3600 604800 86400

;; Query time: 0 msec
;; SERVER: 192.168.0.99#53(192.168.0.99)
;; WHEN: Tue Oct 19 22:32:15 2010
;; MSG SIZE  rcvd: 84

[root]# dig www.yahoo.co.jp
; <<>> DiG 9.2.1 <<>> www.yahoo.co.jp
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22639
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 3, ADDITIONAL: 3

;; QUESTION SECTION:
;www.yahoo.co.jp.               IN      A

;; ANSWER SECTION:
www.yahoo.co.jp.        430     IN      CNAME   www.ya.gl.yahoo.co.jp.
www.ya.gl.yahoo.co.jp.  60      IN      A       203.216.235.201
;; AUTHORITY SECTION:
gl.yahoo.co.jp.         430     IN      NS      gns01.net.djm.yahoo.co.jp.
gl.yahoo.co.jp.         430     IN      NS      gns02.net.bbt.yahoo.co.jp.
gl.yahoo.co.jp.         430     IN      NS      gns01.net.bbt.yahoo.co.jp.

;; ADDITIONAL SECTION:
gns01.net.bbt.yahoo.co.jp. 430  IN      A       202.93.64.132
gns01.net.djm.yahoo.co.jp. 430  IN      A       124.83.159.36
gns02.net.bbt.yahoo.co.jp. 430  IN      A       202.93.64.133

;; Query time: 22 msec
;; SERVER: 192.168.0.99#53(192.168.0.99)
;; WHEN: Tue Oct 19 22:32:31 2010
;; MSG SIZE  rcvd: 197

【DNS】の設定メモ

[root]# pwd
/var/named ←必ずこのディレクトリに居ることを確認しておく!

[root]# /usr/local/src/bind-contrib/contrib/nutshell/h2n -d example.com -n 192.168.0 -s reverie -u p
ostmaster +c /etc/named.conf

 

[root]# more /etc/named.conf
options {
        directory "/var/named";
};
zone "."                        { type hint;    file "db.cache"; };
zone "0.0.127.in-addr.arpa"     { type master;  file "db.127.0.0"; };
zone "example.com"              { type master;  file "db.example"; };
zone "0.168.192.in-addr.arpa"   { type master;  file "db.192.168.0"; };

[root]# chown named.named *
[root]# ls -al
合計 44
drwxr-xr-x    2 named    named        4096 10月 19 21:58 .
drwxr-xr-x   22 root     root         4096 10月 19 21:30 ..
-rw-r--r--    1 named    named          93 10月 19 21:58 boot.cacheonly
-rw-r--r--    1 named    named         149 10月 19 21:58 conf.cacheonly
-rw-r--r--    1 named    named         135 10月 19 21:58 db.127.0.0
-rw-r--r--    1 named    named         146 10月 19 21:58 db.192.168.0
-rw-r--r--    1 named    named         204 10月 19 21:58 db.example
-rw-r--r--    1 named    named         195  1月 25  2003 localhost.zone
-rw-r--r--    1 named    named         177 10月 19 21:58 named.boot
-rw-r--r--    1 named    named        2499  1月 25  2003 named.ca
-rw-r--r--    1 named    named         433  1月 25  2003 named.local

[root]# vi db.127.0.0
$TTL    86400
@ IN SOA  reverie.example.com. postmaster.example.com. ( 2010101901 10800 3600 604800 86400 )
  IN NS   reverie.example.com.

1               PTR     localhost.
[root]# vi db.192.168.0
$TTL    86400
@ IN SOA  reverie.example.com. postmaster.example.com. ( 2010101901 10800 3600 604800 86400 )
  IN NS   reverie.example.com.
                PTR     example.com.
                A       255.255.255.0
99              PTR     reverie.example.com.
[root]# vi db.example
$TTL    86400
@ IN SOA  reverie postmaster ( 2010101901 10800 3600 604800 86400 )
  IN NS   reverie
                        A       192.168.0.0
localhost               A       127.0.0.1
reverie                 A       192.168.0.99
@                       MX      10 reverie
www                     CNAME   reverie
mail                    CNAME   reverie
ftp                     CNAME   reverie

[root]# mv named.ca db.cache

[root]# /etc/rc.d/init.d/named start
起動中:                                             [  OK  ]
[root]# tail /var/log/messages
Oct 19 22:17:37 reverie 10月 19 22:17:37 named: named起動 succeeded
Oct 19 22:17:37 reverie named[1455]: loading configuration from '/etc/named.conf'
Oct 19 22:17:37 reverie named[1455]: no IPv6 interfaces found
Oct 19 22:17:37 reverie named[1455]: listening on IPv4 interface lo, 127.0.0.1#53
Oct 19 22:17:37 reverie named[1455]: listening on IPv4 interface eth0, 192.168.0.99#53
Oct 19 22:17:37 reverie named[1455]: command channel listening on 127.0.0.1#953
Oct 19 22:17:37 reverie named[1455]: zone 0.0.127.in-addr.arpa/IN: loaded serial 2010101901
Oct 19 22:17:37 reverie named[1455]: zone 0.168.192.in-addr.arpa/IN: loaded serial 2010101901
Oct 19 22:17:37 reverie named[1455]: zone example.com/IN: loaded serial 2010101901
Oct 19 22:17:37 reverie named[1455]: running

[root]# named-checkconf
[root]# echo $?
0
[root]# named-checkzone example.com /var/named/db.example
zone example.com/IN: loaded serial 2010101901
OK
[root]# named-checkzone 0.168.192.IN-ADDR.ARPA /var/named/db.192.168.0
zone 0.168.192.IN-ADDR.ARPA/IN: loaded serial 2010101901
OK

【smbclient 】の使用メモ

smbclientは、ftpと同じような感覚で使えるから便利だと思う。

・コマンド実行例
[root]# smbclient '\\win50\temp' -I 192.168.0.50 -U Administrator
added interface ip=192.168.0.99 bcast=192.168.0.255 nmask=255.255.255.0
Password:パスワード入力
Domain=[EXAMPLE.COM] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
smb: \>

【プロンプト表示の変更】メモ

一時的にプロンプト表示を変更するには
下記コマンド投入
export PS1="[\u@\h \W]\\$ "

プロンプト表示設定を固定化するには
上記のコマンドを「~/.bashrc」に追記
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
PS1="[\u]\\$ "

【ログイン接続用TeraTermマクロ】の作成メモ

Linuxサーバ構築の際、リモート接続する事が何度もあるので、ログインする為のマクロツールを作成しておくと便利だ!
※メモとして下記にスクリプトを記載しておく(赤文字部分は環境により任意に変更)
;;-----------------------------------------------------------
; ◆初期設定◆
;;-----------------------------------------------------------
;;▼ttlウィンドウ最小化
show 0
;;▼ユーザ名
username = 'USER'
;;▼IPアドレス
hostname = '192.168.0.99'
;;▼TeraTerm設定ファイル
Ini = 'TERATERM.INI'
;;-----------------------------------------------------------
; ◆マクロの開始◆
;;-----------------------------------------------------------
;;★スタート
:START_CHK

;;▼ログイン接続の編集
SSH_Cmd = ''
SSH_Cmd = hostname
strconcat SSH_Cmd ':22 /ssh'
strconcat SSH_Cmd ' /F='
strconcat SSH_Cmd Ini
strconcat SSH_Cmd ' /user='
strconcat SSH_Cmd username

;;▼MACRO_Start変数の編集
MACRO_Start = ''
MACRO_Start = hostname
strconcat MACRO_Start 'に'
strconcat MACRO_Start username
strconcat MACRO_Start 'でログインします?\n\n'

;;-----------------------------------------------------------
;;▼起動確認
yesnobox MACRO_Start '『TeraTermマクロ起動』'
if result = 1 then
; messagebox 'マクロの起動 ⇒ OK' '『マクロ起動』'
else
goto END
endif

;;▼サーバへSSH接続
connect SSH_Cmd

;;▼プロンプト待ち
wait username

;;▼設定ファイルの再読み込み
restoresetup 'TERATERM_LOGIN.INI'

;;-----------------------------------------------------------
; ◆ユーザの切替◆
;;-----------------------------------------------------------
;;▼ユーザ名変数の値を変更する
OLD_username = username
username = 'root'

;;▼User_ID変数の編集
User_ID = ''
User_ID = username
strconcat User_ID 'のパスワードを入力して下さい!'
strconcat User_ID '\n\n'
strconcat User_ID '※※※ 終了する場合[q]入力 ※※※'
;;-----------------------------------------------------------
;;●改行【1行】
sendln
wait ']#' ']$'
;;-----------------------------------------------------------
;;★パスワードチェック
:PW_CHK
sendln 'su - ' username
wait ':'

;;▼パスワードのインプットボックス
inputbox User_ID '『パスワードの入力』'

;;●[q]キー終了判定
IN_PUT = inputstr
strcompare IN_PUT 'q'
if result = 0 then
sendln
goto END
endif

;;パスワード送信
sendln IN_PUT

;;▼プロンプトで判定
wait username OLD_username
if result = 2 then
messagebox 'パスワード不正' '『ERROR』'
sendln
goto PW_CHK
endif
;;-----------------------------------------------------------
;;▼メッセージボックス
messagebox 'プロンプトを確認' '『プロンプト表示の確認』'

;;-----------------------------------------------------------
; ◆マクロの終了◆
;;-----------------------------------------------------------
;;★マクロの終了
:END
;sendln 'clear'
messagebox 'マクロ終了' '『マクロEND』'
;;-----------------------------------------------------------
; ダイアログボックスを表示
statusbox '3秒後に終了します。' '【終了】'
pause 3
;;-----------------------------------------------------------

【このブログについて】メモ

個人的にメモしておきたいコトを大雑把に書いてます。
(不定期的に更新予定)

動作環境について・・・
・OS :Red Hat Linux 9
・HDD容量:約4.5GB
・メモリ容量:256MB
・使用ソフト:VMware、TeraTerm
・SSH接続によるリモートログイン
・文字コードの設定「EUC」


更新日付

05 2025/06 07
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

RECOMMEND

プロフィール

HN:
Account
HP:
性別:
非公開
職業:
--- NODATA ---
趣味:
--- NODATA ---
自己紹介:
◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…?

リンク

<<前のページ  | HOME | 
Copyright ©  -- LinuC(Linux技術者認定資格)&リナックスサーバ構築設定事例 --  All Rights Reserved
Design by CriCri / Photo by Melonenmann / powered by NINJA TOOLS / 忍者ブログ / [PR]