ページ

2015年2月21日土曜日

ReadyNAS 102 と戯れる 2 - SSH接続 -

SSH接続してみる

1. SSH接続の有効化
    管理者ページから、「システム」> 「設定」を開きSSHを有効にする








2. ターミナルから接続
     ssh root@ReadyNASのIPアドレス
     ※パスワードは管理者ページログイン時のパスワード
Welcome to ReadyNASOS 6.2.2

Last login: Wed Feb 18 22:47:12 2015 from junasa-pc


MySQLを触る

以下操作ログ
root@ReadyJUNAS:~# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.41-0+wheezy1 (Debian)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select user, host from mysql.user;
+------------------+------------+
| user             | host       |
+------------------+------------+
| root             | 127.0.0.1  |
| root             | ::1        |
| debian-sys-maint | localhost  |
| root             | localhost  |
| root             | readyjunas |
+------------------+------------+
5 rows in set (0.06 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

mysql> create database work character set utf8;
Query OK, 1 row affected (0.06 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| work               |
+--------------------+
4 rows in set (0.00 sec)

mysql> grant all privileges on *.* sanji@localhost identified by 'sanji' with grant option;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sanji@localhost identified by 'sanji' with grant option' at line 1
mysql> grant all privileges on *.* to sanji@localhost identified by 'sanji' with grant option;
Query OK, 0 rows affected (0.04 sec)

mysql> select user, host from mysql.user;
+------------------+------------+
| user             | host       |
+------------------+------------+
| root             | 127.0.0.1  |
| root             | ::1        |
| debian-sys-maint | localhost  |
| root             | localhost  |
| sanji            | localhost  |
| root             | readyjunas |
+------------------+------------+
6 rows in set (0.00 sec)

mysql> grant all privileges on *.* to sanji@"%" identified by 'sanji' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> select user, host from mysql.user;
+------------------+------------+
| user             | host       |
+------------------+------------+
| sanji            | %          |
| root             | 127.0.0.1  |
| root             | ::1        |
| debian-sys-maint | localhost  |
| root             | localhost  |
| sanji            | localhost  |
| root             | readyjunas |
+------------------+------------+
7 rows in set (0.00 sec)

mysql> show variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3306  |
+---------------+-------+
1 row in set (0.00 sec)

mysql> exit
Bye

データベース「work」とユーザ「sanji」を作成し、sanjiを外部から接続できるように設定

iptablesの設定
root@ReadyJUNAS:~# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
LeafNetsIN  all  --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain LeafNetsIN (1 references)
target     prot opt source               destination         
root@ReadyJUNAS:~# iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
root@ReadyJUNAS:~# iptables -A INPUT -p tcp --sport 3306 -j ACCEPT
root@ReadyJUNAS:~# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
LeafNetsIN  all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql
ACCEPT     tcp  --  anywhere             anywhere             tcp spt:mysql

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain LeafNetsIN (1 references)
target     prot opt source               destination   

これで外部から接続できるかと思いきや・・・できないorz
また次回がんばります。。

※追記!!
/etc/mysql/my.cnfを修正する事で接続可能になりました^^

↓以下参考
http://d.hatena.ne.jp/uriyuri/20081024/1224798772

クライアントソフトはSequel Proを使用。

















0 件のコメント:

コメントを投稿