パスワードレス SSH ログインを有効にする方法:ssh-keygen と ssh-copy-id を使用した 3 つの簡単なステップ
この記事で説明されているように、ssky-keygen と ssh-copy-id を使用する 3 つの簡単な手順で、パスワードを入力せずにリモート Linux サーバーにログインできます。
ssh-keygen 公開キーと秘密キーを作成します。 ssh-copy-id ローカルホストの公開鍵をリモートホストのauthorized_keysファイルにコピーします。 ssh-copy-id は、リモートホストのホーム、~/.ssh、および ~/.ssh/authorized_keys にも適切な権限を割り当てます。
この記事では、ssh-copy-id の使用に関する 3 つの小さな問題点と、ssh-copy-id を ssh-agent とともに使用する方法についても説明します。
ステップ 1:ローカルホストで ssh-key-gen を使用して公開キーと秘密キーを作成する
jsmith@local-host$ [Note: You are on local-host here] jsmith@local-host$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key] Enter passphrase (empty for no passphrase): [Press enter key] Enter same passphrase again: [Pess enter key] Your identification has been saved in /home/jsmith/.ssh/id_rsa. Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub. The key fingerprint is: 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 jsmith@local-host
ステップ 2:ssh-copy-id を使用して公開キーをリモートホストにコピーする
jsmith@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host jsmith@remote-host's password: Now try logging into the machine, with "ssh 'remote-host'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
注: ssh-copy-id が追加されます リモートホストの .ssh/authorized_key へのキー。
ステップ 3:パスワードを入力せずにリモートホストにログインします
jsmith@local-host$ ssh remote-host Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2 [Note: SSH did not ask for password.] jsmith@remote-host$ [Note: You are on remote-host here]
ほとんどの場合、上記の 3 つの簡単な手順で作業を完了できます。
また、パスワードを入力せずに openSSH から openSSH への SSH および SCP を実行することについても、以前に詳しく説明しました。
SSH2 を使用している場合、SSH2 から SSH2 へ、OpenSSH から SSH2 へ、および SSH2 から OpenSSH へ、パスワードなしで SSH と SCP を実行することについて前述しました。
ssh-add/ssh-agent とともに ssh-copy-id を使用する
オプション -i に値が渡されない場合 および ~/.ssh/identity.pub の場合 は利用できません。ssh-copy-id 次のエラー メッセージが表示されます。
jsmith@local-host$ ssh-copy-id -i remote-host /usr/bin/ssh-copy-id: ERROR: No identities found
ssh-agent にキーをロードしている場合 ssh-add を使用する 、次にssh-copy-id ssh-agent からキーを取得します。 リモートホストにコピーします。つまり、ssh-add -L によって提供されるキーをコピーします。 オプション -i を渡さない場合、コマンドをリモートホストに送信します。 ssh-copy-id に .
jsmith@local-host$ ssh-agent $SHELL jsmith@local-host$ ssh-add -L The agent has no identities. jsmith@local-host$ ssh-add Identity added: /home/jsmith/.ssh/id_rsa (/home/jsmith/.ssh/id_rsa) jsmith@local-host$ ssh-add -L ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsJIEILxftj8aSxMa3d8t6JvM79DyBV aHrtPhTYpq7kIEMUNzApnyxsHpH1tQ/Ow== /home/jsmith/.ssh/id_rsa jsmith@local-host$ ssh-copy-id -i remote-host jsmith@remote-host's password: Now try logging into the machine, with "ssh 'remote-host'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting. [Note: This has added the key displayed by ssh-add -L]
ssh-copy-id の 3 つの小さな問題
以下に、ssh-copy-id に関する小さな問題点をいくつか示します。
この記事が気に入ったら、Delicious にブックマークしてください。 そしてつまずく .
-
chmod 777とは何ですか?Linuxでは何をしますか?
この記事では、ユーザー、グループ、その他にすべての権利を与えるために使用されるLinuxコマンドであるchmod777について説明します。 Linuxの新規ユーザー、ウェブ開発者、またはシステム管理者は、次のように入力するように指示されている可能性があります。 chmod 777 / path / to / file / or / folder …ある時点でLinuxシェルに。 システムで(特にrootとして)コマンドを実行するときは常に、コマンドが何をしているのかを常に知っておく必要があります。では、 chmod 777 本当に? Linuxでの権限 ls –lコマンド 上
-
Linux で CD から ISO を作成し、ユーザー アクティビティを監視し、ブラウザのメモリ使用量を追跡する
ここでも、Linux Tips and Tricks シリーズに関する別の記事を書きました。この投稿の当初の目的は、システム/サーバーを効率的に管理できるようにするための小さなヒントやハックを知っていただくことです。 Linux での Cdrom ISO イメージの作成とユーザーの監視 この記事では、ドライブにロードされた CD/DVD の内容から ISO イメージを作成する方法、学習のためにランダムなマニュアル ページを開く方法、他のログイン ユーザーとそのユーザーの行動の詳細を把握する方法、およびブラウザのメモリ使用量を監視する方法、およびこれらすべてをサードパーティのアプリケーション/