sshで自動ログインしたい

トップオープンソースssh 自動ログイン

ssh 自動ログイン

sshで自動ログインしたい


1.公開キー作成(dsa/rsa)
とりあえず、abcユーザでdsa/rsaをpassなしで作成。

mkdir .ssh
chmod 700

abc@sv:~/.ssh$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/abc/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/abc/.ssh/id_dsa.
Your public key has been saved in /home/abc/.ssh/id_dsa.pub.
The key fingerprint is:
aa:bb:cc:dd:dd:ee:ff:gg:ss:ww:ss:ss:ff:aa:aa:cc abc@sv
The key's randomart image is:
+--[ DSA 1024]----+
| . ooo |
| +.o . |
| . . . .|
| o . . o |
| = S o + |
| . = . . + . |
| E . . + |
| . + o |
| o.o |
+-----------------+
abc@sv:~/.ssh$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/abc/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/abc/.ssh/id_rsa.
Your public key has been saved in /home/abc/.ssh/id_rsa.pub.
The key fingerprint is:
aa:bb:cc:dd:dd:ee:ff:gg:ss:ww:ss:ss:ff:aa:aa:cc abc@sv
The key's randomart image is:
+--[ RSA 2048]----+
|o++o+*...o+.o |
| .+oo = .. o . |
| o E .. . |
| o . o. |
| o S |
| |
| |
| |
| |
+-----------------+

2.相手さんの.sshにそれぞれコピーして、id_dsa.pub/id_rsa.pub
cat id_dsa.pub >> .ssh/authorized_keys2
chmod 600 .ssh/authorized_keys2
rm id_dsa.pub

cat id_rsa.pub >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
rm id_rsa.pub

それでssh ***@ipとすると自動でログイン。






カテゴリ内の記事