--- title: disable ssh password tags: บทความ, sysadmin, debian, linux, security, password, login, ssh --- # ปิดการใช้ Password เข้า SSH > Password เป็นช่องโหว่ความปลอดภัยหนึ่ง เรามาปิดการใช้ password ในการเข้า SSH กัน สำหรับท่านที่มี Linux Server ต้องการปิดการใช้ password ในการเข้า SSH และต้องการให้ใช้ SSH Key เพียงอย่างเดียวในการเข้าถึง server ก่อนอื่นก็ต้อง [สร้าง SSH Key ตามลิงค์บทความ](/@modngan/ssh-keygen) แล้วจึงทำการแก้ไขการตั้งค่าใน SSH ## วิธีการ - ต้องมั่นใจก่อนว่า เราสามารถ ssh เข้า server ได้ด้วย ssh key ก่อน และทำการ ssh เข้า server ไว้ 2 จอ (sessions) เพื่อป้องกันหากตั้งค่า ssh ผิดพลาด - ทำการแก้ไขไฟล์ /etc/ssh/sshd_config ด้วย editor ที่ถนัด ```bash $ sudo vi /etc/ssh/sshd_config ``` - ทำการค้นหาข้อความ Password ใน sshd_config จนกว่าจะพบ `PasswordAuthentication yes` ```config # To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes #PermitEmptyPasswords no ``` - เอาเครื่องหมาย # หน้าบรรทัดออก และแก้ไข yes เป็น no ```config # To disable tunneled clear text passwords, change to no here! PasswordAuthentication no #PermitEmptyPasswords no ``` - ทำการ reload ค่าที่ตั้งใหม่ ด้วยคำสั่ง systemctl reload ```bash $ sudo systemctl reload ssh ``` - จากนั้นทดสอบ ssh เข้าระบบมาใหม่ ![](https://cdn.pixabay.com/photo/2016/10/21/14/56/railway-1758208_960_720.jpg) > ความคิดเห็นคำแนะนำของท่านต่อบทความนี้ จะถูกนำมาใช้ในการพัฒนาปรับปรุงงานเขียนของผม อย่างไงก็รบกวนแสดงความเห็นคิดด้วยนะครับ > > สนับสนุนการเงินได้ที่ > - บัญชีกสิกรไทย 003–3–29344–5