Created
April 19, 2013 02:27
-
-
Save satomixx/5417676 to your computer and use it in GitHub Desktop.
さくらVPS 1GB に CentOS6.4 を入れて、 環境構築1 - ssh など ref: http://qiita.com/items/533f591cf5d79b81a3aa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cat /etc/redhat-release | |
CentOS release 6.4 (Final) | |
# vim /proc/cpuinfo | |
model name : Intel(R) Xeon(R) CPU E5645 | |
cpu MHz : 2400.032 | |
cache size : 4096 KB | |
・・・ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh root@xxx.xxx.xxx.xxx -p 22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir ~/.ssh/[vpsの名前]/ | |
$ cd ~/.ssh/[vpsの名前]/ | |
$ ssh-keygen -t rsa | |
名前の指定部分⇒ id_rsa.[vpsの名前等] | |
パスワード⇒ ご自由に | |
ls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ scp id_rsa.[vpsの名前].pub root@xxx.xxx.xxx.xxx:/home/USER_NAME/.ssh/authorized_keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ssh root@xxx.xxx.xxx.xxx -p 22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# su - USER_NAME | |
$ sudo chown USER_NAME:USER_NAME .ssh/authorized_keys | |
$ chmod 600 /home/USER_NAME/.ssh/authorized_keys | |
$ sudo/etc/init.d/sshd restart | |
$ exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ vim ~/.ssh/config | |
-------- | |
Host [任意のお名前(私はsakura01とかにしました)] | |
HostName xxx.xxx.xxx.xxx | |
Port [サーバーで決めたPort番号] | |
User USER_NAME | |
identityfile ~/.ssh/VPS_NAME/id_rsa.[vpsの名前] # ←ここは.pubじゃありません。.pubはサーバーに送った公開鍵で、ローカルにある鍵のことは秘密鍵といい、ここでは秘密鍵の指定をします。 | |
-------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ssh [先ほど指定した任意のお名前] | |
// ssh sakura01 ←私の場合 | |
ちなみにこれをしないと以下の様なコマンドをほぼ毎回打つことになります。 | |
$ ssh USER_NAME@HostName -p [ポート番号] -i [鍵のパス] | |
めんどいですね(((( ´,,_ゝ`)))) ププッ プルプルッ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo vim /etc/hosts.allow | |
-------- | |
ALL: 127.0.0.1 | |
sshd: .jp | |
-------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo vim /etc/hosts.deny | |
-------- | |
sshd: ALL | |
-------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# useradd USER_NAME -G wheel | |
# passwd USER_NAME | |
# この USER_NAME のところに自由にユーザー名を指定 | |
確認します。 | |
$ id satomi | |
uid=500(satomi) gid=500(satomi) 所属グループ=500(satomi),10(wheel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo yum update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo vim /etc/pam.d/su | |
-------- | |
# auth required pam_wheel.so use_uid | |
↓ | |
auth required pam_wheel.so use_uid | |
-------- | |
コメントアウトを外します。 | |
root権限を使えるグループをwheelに指定します。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo vim /etc/login.defs | |
-------- | |
SU_WHEEL_ONLY yes | |
-------- | |
ファイルの最終行に上の一行を追加ます。 | |
ちなみにvimで最終行に行くには *Shift+g* で行けます。 | |
指定行には */ + [行きたい行数]* もしくは *[行きたい行数] + Shift+g* です。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo visudo | |
-------- | |
# %wheel ALL=(ALL) ALL | |
↓ | |
%wheel ALL=(ALL) ALL | |
-------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo vim /etc/ssh/sshd_config | |
-------- | |
PermitRootLogin no | |
PasswordAuthentication no | |
-------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo vim /etc/ssh/sshd_config | |
-------- | |
Port xxxxx | |
-------- | |
この行をファイルの一番下に追加。 xxxxxは 0 ~ 65535 の間で選択可能。(ホントは49152 ~ 65535という指定があるのですが、今は気にしなくても大丈夫。詳しく知りたい場合はコチラ⇒http://ja.wikipedia.org/wiki/%E3%83%9D%E3%83%BC%E3%83%88%E7%95%AA%E5%8F%B7) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
su - USER_NAME | |
mkdir ~/.ssh/ | |
chmod 700 ~/.ssh/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment