SSH 的架設

一、先下載正宗 ssh-3.2.9.1.tar.gz

(1)教網中心FTP站 ( ftp://ftp.tnc.edu.tw/Sysop/SSH/ssh-3.2.9.1.tar.gz )

(2)ncftp ftp.tnc.edu.tw

cd Sysop

cd SSH

get ssh-3.2.9.1.tar.gz

二、先移除 OpenSSH 相關套件

rpm -e openssh-askpass-gnome

rpm -e openssh-askpass

rpm -e kdessh

rpm -e openssh-clients

rpm -e openssh-server

rpm -e openssh

三、安裝

tar zxvf ssh-3.2.9.1.tar.gz

cd ssh-3.2.9.1

   ./configure --with-libwrap      (準備和 tcp_wrappers 合作共用),產生編譯組態檔

make

make install

四、下載 ssh 的 xinetd 設定檔

(1)教網中心FTP站 ( ftp://ftp.tnc.edu.tw/Sysop/config_files/ssh )

(2)ncftp ftp.tnc.edu.tw

cd sysop

cd config_files

get ssh

將它搬移到 /etc/xinetd.d 目錄下

或是

將以下內容, 存成檔案(檔名 ssh 、目錄是 /etc/xinetd.d )

vi /etc/xinetd.d/ssh
service ssh
{
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/local/sbin/sshd2
server_args = -i
disable = no
}

重新啟動 /etc/rc.d/init.d/xinetd restart

五、啟動與測試

/etc/rc.d/init.d/xinetd restart

telnet localhost 22

quit 可以退出

六、使用方法

ssh2  -l  帳號 主機或IP

查核密碼之後,便可登入主機,操作方式和 telnet 並無太大不同。

例:ssh2 -l admin 163.26.xxx.1

sftp2  帳號@主機或IP

查核密碼之後,便可登入 FTP 傳檔,操作上和 ftp 大同小異。

例:sftp2 admin@163.26.xxx.1

六、用 hosts.allow 和 hosts.deny 限制能夠登入的 IP 範圍

vi /etc/hosts.allow

加入 sshd2,sshd: IP

vi /etc/hosts.deny

加入 sshd2,sshd:All: deny

取消 root 遠端登入

vi /etc/ssh2/sshd2_config

修改 PermitRootLogin yes(將yes 改成 no)