วันอังคารที่ 4 พฤษภาคม พ.ศ. 2553

When you need to ssh to server without entering password.

Loggin into server without password is stupid way. But sometime we need to do that e.g. Cron

So

# CREATE DSA AT CLIENT
user1@client:~$ ssh-keygen -t dsa

Generating public/private dsa key pair.
Enter file in which to save the key (/Users/user1/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/user1/.ssh/id_dsa.
Your public key has been saved in /Users/user1/.ssh/id_dsa.pub.
The key fingerprint is:
9a:30:11:3c:3c:cf:89:01:3a:e1:5d:bd:49:c9:50:f4 user1@client
The key's randomart image is:
+--[ DSA 1024]----+
|. .+.o*o. |
|.o. B. =. |
|o. ..B..oE |
| . ..+o |
| o S |
| o o |
| o |
| |
| |
+-----------------+

# COPY PUBLIC DSA TO SERVER

user1@client:~$ scp ~/.ssh/id_dsa.pub user1@some.server.com:/home/user1/.ssh

user1@some.server.com's password:
id_dsa.pub 100% 642 0.6KB/s 00:00


# SETUP AUTHORIZED_KEY FROM CLIENT TO SERVER
user1@some.server.com:~$ cd ~/.ssh
user1@some.server.com:~$ touch authorized_keys
user1@some.server.com:~$ chmod 600 authorized_keys
user1@some.server.com:~$ cat id_dsa.pub >> authorized_keys


DONE!

ไม่มีความคิดเห็น:

แสดงความคิดเห็น