20 February 2010

เปลี่ยน Port SSH ใน Ubuntu

ใช้ Putty อยู่เกิดอารมณ์ประมาณว่าไม่อยากใช้ Port 22 เข้าใช้งาน Ubuntu ที่อยู่ใน VM ware เลยค้นหาวิธีมาก็ได้ประมาณว่า ให้เข้าไปแก้ไขไฟล์

/etc/ssh/sshd_config

ภายในไฟล์ก็ทำการเปลี่ยน Port จาก 22 เป็นเลขอื่นตามต้องการ

# Package generated configuration file
# See the sshd(8) manpage for details

# What ports, IPs and protocols we listen for
Port 1234
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2

เมื่อทำการแก้ไขแล้วให้ Restart SSH ทีหนึ่งด้วยคำสั่ง

/etc/init.d/ssh restart

แล้วทดสอบเข้าใช้งานดูด้วย

ssh animal@ubuntu -p 1234

animal คือชื่อ username ของผมนะ
@ubuntu เป็น @ชื่อ Host ของเรา
-p 1234 คือ Port 1234 ที่ผมทำการเปลี่ยนใหม่

ถ้าเชื่อต่อไม่ได้ให้ลองตรวจสอบไฟล์ Config ใหม่ดูครับ
**ระวังด้วยนะครับมันจะมีไฟล์ /etc/ssh/ssh_config ไฟล์นี้ไม่ใ่ช่นะครับ

0 comments:

Post a Comment