0%

如何在ubuntu中設定ssh

安裝openssh-server

1
$ apt-get install openssh-server

現在就可以用Putty從遠端登入了,如果要有更佳的安全性,需要做進一步的設定。

修改sshd_config

這個檔案位在/etc/ssh/sshd_config

禁止root帳號login

將設定檔裡面的 PermitRootLogin yes 改成 no

更改login port

修改Port 22

允許特定IP登入

修改/etc/hosts.allow這個檔案

新增 sshd: xxx.xxx.xxx.xxx allow允許特定的IP放行。

拒絕所有IP登入,除了上面已經允許的部分

修改/etc/hosts.deny

新增sshd: all deny

修改設定過後,重新啟動服務

1
$ /etc/init.d/ssh (stop / start / restart)