ページ「MediaWiki:Sidebar」と「OpenSSH 6.1p1」の間の差分
(ページ間の差分)
ナビゲーションに移動
検索に移動
(ページの作成:「 * navigation ** mainpage|mainpage-description ** recentchanges-url|recentchanges ** randompage-url|randompage ** helppage|help-mediawiki * Linux ** コマンドとか|コマンドとか * CentOS ** CentOS Howto|Howto ** CentOS RPM|RPM ** CentOS yum|yum ** CentOS vim|vim ** CentOS 6.5|6.5 ** CentOS 6.10|6.10 ** メモ|メモ * ntp ** ntp Howto|Howto * OpenSSL ** OpenSSL Howto|Howto ** OpenSSL 1.0.1e|1.0.1e * OpenSSH ** OpenSSH 6.1p1|6.1p1 * OpenSSH (by RPM) *…」) |
(ページの作成:「==目的== せっかくなのでリモートでメンテを行えるようにする。<br> クライアントはWindowsXPで[http://www.chiark.greenend.org.uk/%7Esgtatham/putty/ PuTTy]を利用し、通信はSSHで暗号化する。 ==準備== <ul> <li>[http://www.gzip.org/zlib/ zlib] <syntaxhighlight lang="bash"> [root@XXXXX ~]# yum install zlib-devel </syntaxhighlight > <br> </li> <li>tcp_wrappers-devel <syntaxhighlight lang="bash"> [root@XXXXX ~]# yum install tc…」) |
||
1行目: | 1行目: | ||
==目的== | |||
せっかくなのでリモートでメンテを行えるようにする。<br> | |||
クライアントはWindowsXPで[http://www.chiark.greenend.org.uk/%7Esgtatham/putty/ PuTTy]を利用し、通信はSSHで暗号化する。 | |||
==準備== | |||
<ul> | |||
<li>[http://www.gzip.org/zlib/ zlib] | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# yum install zlib-devel | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>tcp_wrappers-devel | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# yum install tcp_wrappers-devel | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>[http://www.openssl.org/ OpenSSL] | |||
</li> | |||
</ul> | |||
* | ==インストール== | ||
** | <ol> | ||
<li>'''ソースの取得''' | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# wget -P /usr/local/src http://ftp.jaist.ac.jp/pub/OpenBSD/OpenSSH/portable/openssh-6.1p1.tar.gz | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>'''ソースの解凍'''<br/> | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# cd /usr/local/src | |||
[root@XXXXX ~]# tar zxvf openssh-6.1p1.tar.gz | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>'''コンパイル設定'''<br/> | |||
([[OpenSSH 6.1p1のconfigureヘルプ]]) | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# cd /usr/local/src/openssh-6.1p1 | |||
[root@XXXXX ~]# ./configure \ | |||
> --prefix=/usr/local/openssh-6.1p1 \ | |||
> --with-tcp-wrappers \ | |||
> --with-ssl-dir=/usr/local/ssl \ | |||
> --with-privsep-user=sshd \ | |||
> --with-privsep-path=/var/empty/sshd | |||
</syntaxhighlight > | |||
<br> | |||
'''tcp_wrappers-devel''' がないとconfigureの途中で怒られる。 | |||
<syntaxhighlight lang="bash"> | |||
checking for libwrap... configure: error: *** libwrap missing | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>'''インストール'''<br/> | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# make | |||
[root@XXXXX ~]# make install | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>'''シンボリックリンクの作成'''<br/> | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# ln -s /usr/local/openssh-6.1p1 /usr/local/ssh | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
</ol> | |||
==設定== | |||
<ol> | |||
<li>'''sshd_confの設定'''<br/> | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# vi /usr/local/ssh/etc/sshd_config | |||
# Port 22 | |||
↓ | |||
Port 22 | |||
# SyslogFacility AUTH | |||
↓ | |||
SyslogFacility AUTH | |||
# PermitRootLogin yes | |||
↓ | |||
PermitRootLogin no ← rootでのログインを禁止 | |||
# PasswordAuthentication yes | |||
↓ | |||
PasswordAuthentication no ← パスワードでのログインを禁止(鍵方式によるログインのみ許可) | |||
# PermitEmptyPasswords no | |||
↓ | |||
PermitEmptyPasswords no ← パスワードなしでのログインを禁止 | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>'''起動スクリプトのコピー'''<br/> | |||
ソースの中にある起動スクリプトをコピーする | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# cp /usr/local/src/openssh-6.1p1/contrib/redhat/sshd.init /etc/rc.d/init.d/sshd | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>'''起動スクリプトの編集'''<br/> | |||
([[OpenSSH 5.9p1のデフォルト起動スクリプト]]) | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# vi /etc/rc.d/init.d/sshd | |||
SSHD=/usr/sbin/sshd | |||
↓ | |||
SSHD=/usr/local/ssh/sbin/sshd | |||
</syntaxhighlight > | |||
start()の中 | |||
<syntaxhighlight lang="bash"> | |||
/usr/bin/ssh-keygen -A | |||
↓ | |||
/usr/local/ssh/bin/ssh-keygen -A | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>'''起動スクリプトの登録'''<br/> | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# chkconfig --add sshd | |||
[root@XXXXX ~]# chkconfig sshd on | |||
[root@XXXXX ~]# chkconfig --list sshd | |||
sshd 0:off 1:off 2:off 3:on 4:on 5:on 6:off | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
</ol> | |||
==鍵の作成== | |||
<ol> | |||
<li>'''一般ユーザーで作成する'''<br/> | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# su - hoge | |||
[hoge@XXXXX ~]$ /usr/local/ssh/bin/ssh-keygen -t rsa ← SSH2で公開鍵・秘密鍵を作成 | |||
Generating public/private rsa key pair. | |||
Enter file in which to save the key (/home/hoge/.ssh/id_rsa): ← 鍵のファイル名を入力(空EnterでOK) | |||
Created directory '/home/hoge/.ssh' | |||
Enter passphrase (empty for no passphrase): ← パスフレーズの入力 | |||
Enter same passphrase again: ← パスフレーズの再入力 | |||
Your identification has been saved in /home/hoge/.ssh/id_rsa. | |||
Your public key has been saved in /home/hoge/.ssh/id_rsa.pub. | |||
The key fingerprint is: | |||
~鍵情報が表示される~ | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>'''作成された鍵の確認'''<br/> | |||
<syntaxhighlight lang="bash"> | |||
[hoge@XXXXX ~]$ cd .ssh | |||
[hoge@XXXXX ~]$ ls -la | |||
合計 16 | |||
drwx------ 2 XXXXX XXXXX 4096 3月 8 21:22 . | |||
drwx------ 16 XXXXX XXXXX 4096 3月 8 20:33 .. | |||
-rw------- 1 XXXXX XXXXX 951 3月 8 21:22 id_rsa ← 秘密鍵 | |||
-rw-r--r-- 1 XXXXX XXXXX 241 3月 8 21:22 id_rsa.pub ← 公開鍵 | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>'''公開鍵の名前の変更'''<br/> | |||
<ul> | |||
<li>authorized_keysが既存の場合 | |||
<syntaxhighlight lang="bash"> | |||
[hoge@XXXXX ~]$ cd ~/.ssh | |||
[hoge@XXXXX ~]$ cat id_rsa.pub >> authorized_keys | |||
[hoge@XXXXX ~]$ rm -f ~/.ssh/id_rsa.pub ← 元の鍵を削除 | |||
</syntaxhighlight > | |||
</li> | |||
<li>authorized_keysがない場合 | |||
<syntaxhighlight lang="bash"> | |||
[hoge@XXXXX ~]$ cd ~/.ssh | |||
[hoge@XXXXX ~]$ mv id_rsa.pub authorized_keys | |||
</syntaxhighlight > | |||
</li> | |||
</ul> | |||
<br> | |||
</li> | |||
<li>'''公開鍵の権限の変更'''<br/> | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# chmod 400 ~/.ssh/authorized_keys | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
<li>'''フロッピーにコピー'''<br/> | |||
id_rsaファイルをフロッピーにコピーする。<br/> | |||
([[CentOS_Howto#フロッピーのマウント|フロッピーのマウント]]) | |||
<syntaxhighlight lang="bash"> | |||
[root@XXXXX ~]# cp /home/hoge/.ssh/id_rsa /mnt/floppy | |||
</syntaxhighlight > | |||
<br> | |||
</li> | |||
</ol> | |||
フロッピーにコピーされたid_rsaファイルを使用してPuTTyの接続設定を行う。 | |||
2023年5月11日 (木) 09:16時点における最新版
目的
せっかくなのでリモートでメンテを行えるようにする。
クライアントはWindowsXPでPuTTyを利用し、通信はSSHで暗号化する。
準備
- zlib
[root@XXXXX ~]# yum install zlib-devel
- tcp_wrappers-devel
[root@XXXXX ~]# yum install tcp_wrappers-devel
- OpenSSL
インストール
- ソースの取得
[root@XXXXX ~]# wget -P /usr/local/src http://ftp.jaist.ac.jp/pub/OpenBSD/OpenSSH/portable/openssh-6.1p1.tar.gz
- ソースの解凍
[root@XXXXX ~]# cd /usr/local/src [root@XXXXX ~]# tar zxvf openssh-6.1p1.tar.gz
- コンパイル設定
(OpenSSH 6.1p1のconfigureヘルプ)[root@XXXXX ~]# cd /usr/local/src/openssh-6.1p1 [root@XXXXX ~]# ./configure \ > --prefix=/usr/local/openssh-6.1p1 \ > --with-tcp-wrappers \ > --with-ssl-dir=/usr/local/ssl \ > --with-privsep-user=sshd \ > --with-privsep-path=/var/empty/sshd
tcp_wrappers-devel がないとconfigureの途中で怒られる。checking for libwrap... configure: error: *** libwrap missing
- インストール
[root@XXXXX ~]# make [root@XXXXX ~]# make install
- シンボリックリンクの作成
[root@XXXXX ~]# ln -s /usr/local/openssh-6.1p1 /usr/local/ssh
設定
- sshd_confの設定
[root@XXXXX ~]# vi /usr/local/ssh/etc/sshd_config # Port 22 ↓ Port 22 # SyslogFacility AUTH ↓ SyslogFacility AUTH # PermitRootLogin yes ↓ PermitRootLogin no ← rootでのログインを禁止 # PasswordAuthentication yes ↓ PasswordAuthentication no ← パスワードでのログインを禁止(鍵方式によるログインのみ許可) # PermitEmptyPasswords no ↓ PermitEmptyPasswords no ← パスワードなしでのログインを禁止
- 起動スクリプトのコピー
ソースの中にある起動スクリプトをコピーする[root@XXXXX ~]# cp /usr/local/src/openssh-6.1p1/contrib/redhat/sshd.init /etc/rc.d/init.d/sshd
- 起動スクリプトの編集
(OpenSSH 5.9p1のデフォルト起動スクリプト)[root@XXXXX ~]# vi /etc/rc.d/init.d/sshd SSHD=/usr/sbin/sshd ↓ SSHD=/usr/local/ssh/sbin/sshd
start()の中
/usr/bin/ssh-keygen -A ↓ /usr/local/ssh/bin/ssh-keygen -A
- 起動スクリプトの登録
[root@XXXXX ~]# chkconfig --add sshd [root@XXXXX ~]# chkconfig sshd on [root@XXXXX ~]# chkconfig --list sshd sshd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
鍵の作成
- 一般ユーザーで作成する
[root@XXXXX ~]# su - hoge [hoge@XXXXX ~]$ /usr/local/ssh/bin/ssh-keygen -t rsa ← SSH2で公開鍵・秘密鍵を作成 Generating public/private rsa key pair. Enter file in which to save the key (/home/hoge/.ssh/id_rsa): ← 鍵のファイル名を入力(空EnterでOK) Created directory '/home/hoge/.ssh' Enter passphrase (empty for no passphrase): ← パスフレーズの入力 Enter same passphrase again: ← パスフレーズの再入力 Your identification has been saved in /home/hoge/.ssh/id_rsa. Your public key has been saved in /home/hoge/.ssh/id_rsa.pub. The key fingerprint is: ~鍵情報が表示される~
- 作成された鍵の確認
[hoge@XXXXX ~]$ cd .ssh [hoge@XXXXX ~]$ ls -la 合計 16 drwx------ 2 XXXXX XXXXX 4096 3月 8 21:22 . drwx------ 16 XXXXX XXXXX 4096 3月 8 20:33 .. -rw------- 1 XXXXX XXXXX 951 3月 8 21:22 id_rsa ← 秘密鍵 -rw-r--r-- 1 XXXXX XXXXX 241 3月 8 21:22 id_rsa.pub ← 公開鍵
- 公開鍵の名前の変更
- authorized_keysが既存の場合
[hoge@XXXXX ~]$ cd ~/.ssh [hoge@XXXXX ~]$ cat id_rsa.pub >> authorized_keys [hoge@XXXXX ~]$ rm -f ~/.ssh/id_rsa.pub ← 元の鍵を削除
- authorized_keysがない場合
[hoge@XXXXX ~]$ cd ~/.ssh [hoge@XXXXX ~]$ mv id_rsa.pub authorized_keys
- authorized_keysが既存の場合
- 公開鍵の権限の変更
[root@XXXXX ~]# chmod 400 ~/.ssh/authorized_keys
- フロッピーにコピー
id_rsaファイルをフロッピーにコピーする。
(フロッピーのマウント)[root@XXXXX ~]# cp /home/hoge/.ssh/id_rsa /mnt/floppy
フロッピーにコピーされたid_rsaファイルを使用してPuTTyの接続設定を行う。