このドキュメントで説明するソフトウェアは、Extended SupportまたはSustaining Supportのいずれかにあります。 詳細は、https://www.oracle.com/us/support/library/enterprise-linux-support-policies-069172.pdfを参照してください。
Oracleでは、このドキュメントに記載されているソフトウェアをできるだけ早くアップグレードすることをお薦めします。
OpenSSHユーティリティを使用して、リモート・システムに接続するたびにパスワードを指定せずにアクセスする手順は、次のとおりです。
ssh-keygenを使用して、次の例のように公開キーと秘密キーのペアを生成します。
$
ssh-keygen
Generating public/private rsa key pair. Enter file in which to save the key (/home/user
/.ssh/id_rsa):<Enter>
Created directory '/home/user
/.ssh'. Enter passphrase (empty for no passphrase):<Enter>
Enter same passphrase again:<Enter>
...このコマンドによってパスフレーズの入力が求められるたびに、
[Enter]
を押します。ssh-copy-idスクリプトを使用して、次の例のように
~/.ssh/id_rsa.pub
ファイルの公開キーをリモート・システムの~/.ssh/authorized_keys
ファイルに追加します。$
ssh-copy-id
remote_user
@host
remote_user
@host
's password:
Now try logging into the machine, with "ssh 'remote_password
remote_user
@host
'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.プロンプトが表示されたら、リモート・システムのパスワードを入力します。
このスクリプトは、リモート・システムの
~/.ssh
および~/.ssh/authorized_keys
の権限も変更して、ユーザーのグループによるアクセスを禁止します。これで、OpenSSHユーティリティを使用して、リモート・システムにパスワードを指定せずにアクセスできます。 スクリプトの表示に従って、sshを使用してリモート・システムにログインし、
~/.ssh/authorized_keys
ファイルに接続元のシステムのキーのみが含まれていることを確認します。 次に例を示します。$
ssh
remote_user
@host
Last login: Thu Jun 13 08:33:58 2013 fromlocal_host
host
$cat .ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6OabJhWABsZ4F3mcjEPT3sxnXx1OoUcvuCiM6fg5s/ER ... FF488hBOk2ebpo38fHPPK1/rsOEKX9Kp9QWH+IfASI8q09xQ==local_user
@local_host
host
$logout
Connection tohost
closed. $リモート
~/.ssh
ディレクトリおよび~/.ssh/authorized_keys
ファイルのアクセス権限がユーザーのみに許可されていることを確認します。$
ssh
total 4 drwx------+ 2remote_user
@host
ls -al .sshremote_user
group
5 Jun 12 08:33 . drwxr-xr-x+ 3remote_user
group
9 Jun 12 08:32 .. -rw-------+ 1remote_user
group
397 Jun 12 08:33 authorized_keys $ssh
# file: .ssh # owner:remote_user
@host
getfacl .sshremote_user
# group:group
user::rwx group::--- mask::rwx other::--- $ssh
# file: .ssh/authorized_keys # owner:remote_user
@host
getfacl .ssh/authorized_keysremote_user
# group:group
user::rw- group::--- mask::rwx other::---必要に応じて、権限を変更してください。
$
ssh
$remote_user
@host
'umask 077; /sbin/restorecon .ssh'ssh
remote_user
@host
'umask 077; /sbin/restorecon .ssh/authorized_keys'ノートユーザー名がクライアント・システムとサーバー・システムで同じ場合は、リモート・ユーザー名と
@
記号を指定する必要はありません。ユーザー名がクライアント・システムとサーバー・システムで異なる場合は、次の例のようにローカル・ユーザー名を定義する、権限が600の
~/.ssh/config
ファイルをリモート・システムに作成します。$
ssh
$remote_user
@host
echo -e "Host *\\\nUserlocal_user
" '>>' .ssh/configssh
Host * Userremote_user
@host
cat .ssh/configlocal_user
$ssh
remote_user
@host
'umask 077; /sbin/restorecon .ssh/config'これで、次の例のようにリモート・ユーザー名の指定が不要のリモート・システムへのアクセスが可能になります。
$
ssh
-rw-------+ 1host
ls -l .ssh/configremote_user
group
37 Jun 12 08:34 .ssh/config $ssh
# file: .ssh/config # owner:host
getfacl .ssh/configremote_user
# group:group
user::rw- group::--- mask::rwx other::---
詳細は、ssh-copy-id(1)
、ssh-keygen(1)
およびssh_config(5)
の各マニュアル・ページを参照してください。