ระบบที่ทำการทดสอบ
- OpenSSH Client บน Mac OS X 10.5.6
- OpenSSH Server บน Ubuntu 8.04
ขั้นตอนแรก ทำการสร้าง keys สำหรับยืนยันตัวตนระหว่าง Client และ Server (ทำบนเครื่อง Client ในที่นี้คือ Mac OS X)
MacClient:~ UserA$ ssh-keygen -t rsa
MacClient:~ UserA$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/UserA/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/UserA/.ssh/id_rsa.
Your public key has been saved in /Users/UserA/.ssh/id_rsa.pub.
The key fingerprint is:
a4:74:0b:bc:2f:d1:f5:c7:4e:90:51:7f:f4:45:84:a0 UserA@MacClient
ขั้นตอนต่อไป ใช้ ssh สร้าง directory ~/.ssh บน Server ปลายทาง (ทำบน Client ได้เลย โดยผ่าน ssh)
MacClient:~ UserA$ ssh UserA@UbuntuServer mkdir -p .ssh
MacClient:~ UserA$ ssh UserA@UbuntuServer mkdir -p .ssh
UserA@vmtuserver's password:
ขั้นตอนสุดท้าย ทำการเพิ่ม Public keys ที่สร้างขึ้นในขั้นตอนแรกไปยังไฟล์ ~/.ssh/authorized_keys บน Server ปลายทาง (ทำบน Client โดยผ่าน ssh เช่นเคย)
MacClient:~ UserA$ cat .ssh/id_rsa | ssh UserA@UbuntuServer 'cat >> .ssh/authorized_keys'
MacClient:~ UserA$ cat .ssh/id_rsa | ssh UserA@UbuntuServer 'cat >> .ssh/authorized_keys'
UserA@vmtuserver's password:
ทำการทดสอบ
MacClient:~ UserA$ ssh UserA@UbuntuServer
MacClient:~ UserA$ ssh UserA@UbuntuServer
Linux UbuntuServer 2.6.24-19-server #1 SMP Wed Jun 18 15:18:00 UTC 2008 i686
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/
You have mail.
Last login: Tue Jan 13 00:14:19 2009 from MacClient
UserA@UbuntuServer:~$
*สามารถเพิ่ม Public keys ที่สร้างขึ้นไปยัง User ใดๆ ก็ได้ ไม่จำเป็นต้องมีชื่อเหมือนกับ User ที่มีอยู่บน Client
ขอบพระคุณเจ้าของบทความมากๆ เลยครับลดปัญหาของผมได้เยอะเลย
ไม่มีความคิดเห็น:
แสดงความคิดเห็น