linux啟動ssh服務

來源:互聯網
上載者:User

本地用虛擬機器,登進去shell視窗操作起來不太方便,vmware中命令列模式下,只有一屏的內容,編輯檔案等操作時很不方便,於是就想起個ssh服務連,碰到些問題,記錄一下。

1. 編輯/etc/ssh/sshd_config

# This is ssh server systemwide configuration file.
Port 22
ListenAddress 192.168.1.1
HostKey /etc/ssh/ssh_host_key
ServerKeyBits 1024
LoginGraceTime 600
KeyRegenerationInterval 3600
PermitRootLogin no
IgnoreRhosts yes
IgnoreUserKnownHosts yes
StrictModes yes
X11Forwarding no
PrintMotd yes
SyslogFacility AUTH
LogLevel INFO
RhostsAuthentication no
RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication yes
PermitEmptyPasswords no
AllowUsers admin

下面逐行說明上面的選項設定:

Port 22
   “Port”設定sshd*jtq*的連接埠號碼。

ListenAddress 192.168.1.1
    “ListenAddress”設定sshd伺服器綁定的IP地址。

HostKey /etc/ssh/ssh_host_key

    “HostKey”設定包含電腦私人密匙的檔案。

ServerKeyBits 1024
     “ServerKeyBits”定義伺服器密匙的位元。

LoginGraceTime 600
     “LoginGraceTime”設定如果使用者不能成功登入,在切斷串連之前伺服器需要等待的時間(以秒為單位)。

KeyRegenerationInterval 3600
    “KeyRegenerationInterval”設定在多少秒之後自動重建伺服器的密匙(如果使用密匙)。重建密匙是為了防止用盜用的密匙解密被截獲的資訊。

PermitRootLogin no
    “PermitRootLogin”設定root能不能用ssh登入。這個選項一定不要設成“yes”。

IgnoreRhosts yes
    “IgnoreRhosts”設定驗證的時候是否使用“rhosts”和“shosts”檔案。

IgnoreUserKnownHosts yes
    “IgnoreUserKnownHosts”設定ssh daemon是否在進行RhostsRSAAuthentication安全驗證的時候忽略使用者的“$HOME/.ssh/known_hosts”

StrictModes yes
      “StrictModes”設定ssh在接收登入請求之前是否檢查使用者家目錄和rhosts檔案的許可權和所有權。這通常是必要的,因為新手經常會把自己的目錄和檔案設成任何人都有寫權 限。

X11Forwarding no
“X11Forwarding”設定是否允許X11轉寄。

PrintMotd yes
“PrintMotd”設定sshd是否在使用者登入的時候顯示“/etc/motd”中的資訊。

SyslogFacility AUTH
“SyslogFacility”設定在記錄來自sshd的訊息的時候,是否給出“facility code”。

LogLevel INFO
“LogLevel”設定記錄sshd日誌訊息的層次。INFO是一個好的選擇。查看sshd的man協助頁,已擷取更多的資訊。

RhostsAuthentication no
“RhostsAuthentication”設定只用rhosts或“/etc/hosts.equiv”進行安全驗證是否已經足夠了。

RhostsRSAAuthentication no
“RhostsRSA”設定是否允許用rhosts或“/etc/hosts.equiv”加上RSA進行安全驗證。

RSAAuthentication yes
 “RSAAuthentication”設定是否允許只有RSA安全驗證。

PasswordAuthentication yes
“PasswordAuthentication”設定是否允許口令驗證。

PermitEmptyPasswords no
“PermitEmptyPasswords”設定是否允許用口令為空白的帳號登入。

AllowUsers admin
 “AllowUsers”的後面可以跟著任意的數量的使用者名稱的匹配串(patterns)或user@host這樣的匹配串,這些字串用空格隔開。主機名稱可以是DNS名或IP地址

上面是從百度文庫一篇說明中複製過來的。之後運行/etc/init.d/sshd restart提示:

Disabling protocol version 2. Could not load host key
sshd: no hostkeys available — exiting

再編輯sshd_config檔案,取消掉下面2行的注釋:

HostKey /etc/ssh/ssh_host_rsa_key

HostKey /etc/ssh/ssh_host_dsa_key

說明:這2行是為ssh協議版本2配置(檔案裡有注釋)

service sshd restart

完成

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.