Linux sshキーなしログイン

1956 ワード

1.ワンウェイキーレス構成


station213 -> station220:

ステップ1:


コマンドを入力:ssh-keygenは一路車に戻ります.
[root@station213 ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? 

ステップ2:


生成ファイル:id_rsa  id_rsa.pub
[root@station213 ~]# cd ~/.ssh/
[root@station213 .ssh]# ls
id_rsa  id_rsa.pub  known_hosts

手順3:


コピーファイル:id_rsa.pubはターゲットマシンstation 220に、authorized_と名前を変更します.keys
[root@station213 .ssh]# scp id_rsa.pub 192.168.101.220:~/.ssh/authorized_keys

手順4:


ログイン検証:パスワードの入力を求めるメッセージがなく、鍵なしログイン構成に成功しました.
[root@station213 .ssh]# ssh 192.168.101.220
Last login: Fri Mar 22 11:18:25 2013 from 192.168.101.213
[root@station220 ~]# 

双方向の鍵なし構成は同じです...

2.複数のマシン間の鍵なし構成

は、例えば、station 213->station 220:
                station220 -> station213:

ステップ1:


station213 -> station220:
[root@station213 .ssh]# ssh-copy-id -i id_rsa.pub [email protected]
10
Now try logging into the machine, with "ssh '[email protected]'", and check in:


  .ssh/authorized_keys


to make sure we haven't added extra keys that you weren't expecting.


[root@station213 .ssh]# ssh-copy-id -i id_rsa.pub [email protected]
10
[email protected]'s password: 
Now try logging into the machine, with "ssh '[email protected]'", and check in:


  .ssh/authorized_keys


to make sure we haven't added extra keys that you weren't expecting.


[root@station213 .ssh]# ssh 192.168.101.220
Last login: Fri Mar 22 11:30:05 2013 from 192.168.101.213
[root@station220 ~]# 

ステップ2:


station 213->station 221:上.