歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> Linux系統中OpenSSH的安裝和配置之三

Linux系統中OpenSSH的安裝和配置之三

日期:2017/2/27 9:46:24   编辑:更多Linux
  配置OpenSSH使其使用TCP-Wrappers inetd超級服務器 TCP-WRAPPERS用來啟動和停止sshd1服務。當inetd運行的時候,它會從配置文件(默認為“/etc/inetd.conf”)中讀入配置信息。在配置文件中每一行的不同項是用TAB或空格分開。 第一步 編輯“inetd.conf”文件(vi /etc/inetd.conf)並加入這一行: ssh stream tcp nowait root /usr/sbin/tcpd sshd –i 注意:“-i”參數很重要,它說明sshd是被inetd運行的。在加入這一行後,通過發送一個SIGHUP信號(killall –HUP inetd)來更新“inetd.conf”文件。 [root@deep /root]? killall -HUP inetd 第二步 編輯“hosts.allow”文件(vi /etc/hosts.allow)並加入這一行: sshd: 192.168.1.4 win.openarch.com 這一行表示IP地址為“192.168.1.4”,主機名為“win.openarch.com”的計算機允許用ssh訪問服務器。 下面這些“daemon”字符串(用於TCP-WRAPPERS)被sshd1使用: sshdfwd-X11 (允許/禁止X11轉發). sshdfwd-[port-number] (TCP轉發). sshdfwd-[port-name] (port-name在/etc/services中定義。用於TCP轉發). 注意:如果准備使用ssh,一定要用在所有的服務器上。如果十台安全的服務器和一台不安全的服務器配在一起,也談不上什麼安全性。 更多的資料 如果想查找詳細的資料可以用man命令查幫助頁,讀取相關信息: $ man ssh (1) - OpenSSH secure shell client (remote login program) $ man ssh [slogin] (1) - OpenSSH secure shell client (remote login program) $ man ssh-add (1) - adds identities for the authentication agent $ man ssh-agent (1) - authentication agent $ man ssh-keygen (1) - authentication key generation $ man sshd (8) - secure shell daemon SSH1每用戶配置 第一步 為本地服務器創建私有和公用密匙,執行下面的命令: [root@deep]# su username [username@deep]$ ssh-keygen1 舉個例子,顯示出來的結果可能是: Initializing random number generator... Generating p: ............................++ (distance 430) Generating q: ......................++ (distance 456) Computing the keys... Testing the keys... Key generation complete. Enter file in which to save the key (/home/username/.ssh/identity): 【按下回車鍵】 Enter passphrase: Enter the same passphrase again: Your identification has been saved in /home/username/.ssh/identity. Your public key is: 1024 37 14937757511251955533691120318477293862290049394715136511145806108870001764378494676831 29757784315853227236120610062314604405364871843677484233240919418480988907860997175244 46977589647127757030728779973708569993017043141563536333068888944038178461608592483844 590202154102756903055846534063365635584899765402181 [email protected] Your public key has been saved in /home/username/.ssh/identity.pub 注意:如果有多個帳號需要為每個帳號創建一個密匙。


你可能要為下面的服務器創建密匙: l Mail服務器 l Web服務器 l 網關服務器 這允許對這些服務器進行有限的訪問,例如,不允許用Mail服務器的帳號訪問Web服務器或網關服務器。這樣可以增加整體的安全性,即使因為某種原因有一個密匙被洩密了,也不會影響到其它的服務器。 第二步 把本機的公用密匙(identity.pub)拷貝到遠程主機的“/home/username/.ssh”目錄下,例如,使用“authorized_keys”這個名字。 注意:拷貝文件的一個方法使用FTP命令,另一個辦法是把公用密匙用email(包含“~/.ssh/identity.pub”文件的內容)發給系統管理員。 改變pass-phrase 用加上“-p”參數的“ssh-keygen”命令,在任何時候都可以改變pass-phrase。用下面的命令,改變pass-phrase: [root@deep]# su username [username@deep]$ ssh-keygen1 –p Enter file key is in (/home/username/.ssh/identity): [按下回車鍵] Enter old passphrase: Key has comment '[email protected]' Enter new passphrase: Enter the same passphrase again: Your identification has been saved with the new passphrase. OpenSSH用戶工具 下面列出的是一些我們經常要用到的命令,當然還有很多其它的命令,更詳細的信息可以查看man幫助頁或其它文檔。 ssh ssh(Secure Shell)是用來登錄遠程計算機和在遠程計算機上執行命令的程序。它是用來替代rlogin和rsh,以及在不安全的網絡環境下在兩台計算機之間提供安全和加密的信息交流。X11連接和TCP/IP端口可以被轉發到一個安全的通道裡。 用下面的命令,登錄遠程計算機: [root@deep]# ssh [login_name] [hostname] 例如: [root@deep]# ssh username www.openarch.com [email protected]'s passWord: Last login: Tue Oct 19 1999 18:13:00 -0400 from gate.openarch.com Welcome to www.openarch.com on Deepforest. [login_name]是用來登錄ssh服務器的用戶名,[hostname]是ssh服務器主機的地址。 scp 可以用這個命令把文件從本地計算機拷貝到遠程計算機,或者反之,甚至可以在兩台遠程計算機之間用“scp”命令拷貝文件。把遠程主機上的文件拷貝到當前目錄的一個簡單的方法如下。 用下面的命令把文件從遠程主機拷貝到本地主機上: [root@deep /]# su admin [admin@deep /]$ scp -p [login_name@hostname]:/dir/for/file localdir/to/filelocation 例如: [username@deep]$ scp -p username@mail:/etc/test1 /tmp Enter passphrase for RSA key '[email protected]': test1 2 KB 2.0 kB/s ETA: 00:00:00 100% 用下面的命令把文件從本地主機拷貝到遠程主機上: [root@deep /]# su admin [admin@deep /]$ scp -p localdir/to/filelocation [username@hostname]:/dir/for/file 例如: [username@deep]$ scp -p /usr/bin/test2 username@mail:/var/tmp username@mail's password: test2 7 KB 7.9 kB/s ETA: 00:00:00 100% 注意:“-p”選項表示文件的改變和訪問時間屬性以及權限,在拷貝過程中被保留。通常是需要這樣的。 安裝到系統中的文件 # /etc/ssh # /etc/ssh/ssh_config # /etc/ssh/sshd_config # /etc/ssh_host_key

# /etc/ssh_host_key.pub # /usr/bin/ssh # /usr/bin/slogin # /usr/man/man1/ssh.1 # /usr/man/man1/scp.1 # /usr/man/man1/ssh-add.1 # /usr/man/man1/ssh-agent.1 # /usr/man/man1/ssh-keygen.1 # /usr/bin/scp # /usr/bin/ssh-add # /usr/bin/ssh-agent # /usr/bin/ssh-keygen # /usr/man/man1/slogin.1 # /usr/man/man8/sshd.8 # /usr/sbin/sshd Windows平台上免費的SSH客戶軟件 Putty Putty的主頁:http://www.chiark.greenend.org.uk/~sgtatham/putty.Html Tera Term Pro and TTSSH Tera Term Pro的主頁:http://hp.vector.co.jp/authors/VA002416/teraterm.html TTSSH Homepage:http://www.zip.com.au/~roca/download.html 版權說明 這篇文章翻譯和改編自Gerhard Mourani的《Securing and Optimizing Linux: RedHat Edition》,原文及其版權協議請參考:http://www.openna.com/。 中文版的版權屬於作者brimmer



# /usr/man/man1/ssh.1 # /usr/man/man1/scp.1 # /usr/man/man1/ssh-add.1 # /usr/man/man1/ssh-agent.1 # /usr/man/man1/ssh-keygen.1 # /usr/bin/scp # /usr/bin/ssh-add # /usr/bin/ssh-agent # /usr/bin/ssh-keygen # /usr/man/man1/slogin.1 # /usr/man/man8/sshd.8 # /usr/sbin/sshd Windows平台上免費的SSH客戶軟件 Putty Putty的主頁:http://www.chiark.greenend.org.uk/~sgtatham/putty.html Tera Term Pro and TTSSH Tera Term Pro的主頁:http://hp.vector.co.jp/authors/VA002416/teraterm.html TTSSH Homepage:http://www.zip.com.au/~roca/download.html 版權說明 這篇文章翻譯和改編自Gerhard Mourani的《Securing and Optimizing Linux: RedHat Edition》,原文及其版權協議請參考:http://www.openna.com/。 中文版的版權屬於作者brimmer



Copyright © Linux教程網 All Rights Reserved