まずはSSHで接続。
rootで接続
ユーザの作成
[html]
$ useradd user
$ passwd user
[/html]
sudo権限付与
[html]
#wheelグループに追加
$ usermod -G wheel user名
#追加されているかどうか確認 wheelがあればOK
$ id user名
uid=500(YYYYY) gid=500(YYYYY) groups=500(YYYYY),10(wheel)
[/html]
セキュリティー
SSHログイン設定
[html]
sudo vim /etc/ssh/sshd_config
[/html]
rootログイン禁止
[html]
#PermitRootLogin yesPermitRootLogin no
[/html]
SSH再起動
[html]
sudo /etc/rc.d/init.d/sshd restart
[/html]
iptablesの設定
ファイアウォール機能
[html]
#httpのポートを指定(80)
sudo iptables -A INPUT -p tcp -m tcp –dport 80 -j ACCEPT
#httpsのポートを指定(443)
sudo iptables -A INPUT -p tcp -m tcp –dport 443 -j ACCEPT
#sshのポートを指定(xxxx)
sudo iptables -A INPUT -p tcp -m tcp –dport xxxx -j ACCEPT
[/html]
sudoの再起動
[html]
#設定の保存
sudo service iptables save
#再起動
sudo service iptables restart
[/html]
yumのアップデート
[html]sudo yum update
[/html]
wheelグループがsudoコマンドを使えるように
設定ファイルを開く
[html]
$ visudo
[/html]
コメントアウトを消す
[html]
## Allows people in group wheel to run all commands
#%wheel ALL=(ALL) ALL
%wheel ALL=(ALL) ALL
[/html]
コンソールの日本語化
[html]
$ vi /etc/sysconfig/i18n
# 変更前
LANG="C"
SYSFONT="latarcyrhed-sun16"
#変更後
LANG="ja_JP.UTF-8"
SYSFONT="latarcyrhed-sun16"
[/html]
MacでSSH接続
[html]
# ssh root@xxx.xxx.xxx.xxx -p 22
[/html]
Mac公開鍵
[html]
$ssh-keygen
[/html]
パーミッション変更
[html]
$ cd
$ cd .ssh
$ chmod 600 id_rsa[/html]
サーバへ公開鍵を送信する
[html]
$ cd
$ cd .ssh
$ scp -P 22 id_rsa.pub xxxx@xxx.xxx.xxx.xxx;
[/html]
参考ページ
rootパスワード変更ユーザ作成
公開鍵・秘密鍵生成forMac サーバセット
http://akabeko.me/blog/2012/04/revps-01-prepare-ssh-key/
http://to-developer.com/blog/?p=563
Viコマンド
http://net-newbie.com/linux/commands/vi.html
再インストールしたらMACでSSH接続が出来なくなった。
エラー「Host key verification failed」
古いホストキーがあるのが問題みたい。
解決法
[html]
$ ssh-keygen -F ホスト名
$ ssh-keygen -R ホスト名
[/html]
ホストキーが削除されて接続できた。