Nruab SSH-server hauv Ubuntu

Pin
Send
Share
Send

Lub SSH raws tu qauv yog siv los muab kev tiv thaiv kev nyab xeeb rau lub khoos phis tawm, uas tso cai rau cov chaw taws teeb tswj tsis tau tsuas yog los ntawm lub plhaub ntawm cov txheej txheem ua haujlwm, tab sis kuj siv los ntawm ib qho channel. Qee zaum cov neeg siv ntawm Ubuntu lub operating system muaj qhov xav tau tso tus SSH server rau ntawm lawv lub PC rau ib qho hom phiaj twg. Yog li ntawd, peb xav kom koj paub koj tus kheej nrog cov txheej txheem no hauv kev nthuav dav, tau kawm tsis tsuas yog cov txheej txheem kev thau khoom, tab sis kuj hais txog kev teeb tsa ntawm cov khoom tseem ceeb.

Nruab SSH-server hauv Ubuntu

SSH cov khoom ntxiv muaj rau rub tawm los ntawm cov chaw muab pov thawj, vim tias peb yuav xav tsuas yog siv hom ntawd xwb, nws yog qhov feem ntau ruaj khov thiab txhim khu kev qha, thiab tseem tsis ua teeb meem rau cov neeg siv cov novice. Peb faib tag nrho cov txheej txheem rau hauv cov kauj ruam, yog li nws yuav yooj yim dua rau koj los ntawm cov lus qhia. Cia peb pib los ntawm thaum pib.

Kauj ruam 1: Rub tawm thiab nruab SSH-server

Peb yuav ua qhov haujlwm dhau los "Chaw Nres Tsheb" siv cov txheej txheem yooj yim ntawm cov lus txib. Koj tsis tas yuav muaj kev paub ntxiv lossis kev txawj ntse, koj yuav tau txais cov ncauj lus qhia ntxaws ntawm txhua qhov haujlwm thiab txhua cov lus txib tsim nyog.

  1. Tua tawm lub console los ntawm cov ntawv qhia zaub mov lossis tuav qhov sib koom ua ke Ctrl + kev + T.
  2. Tam sim pib pib rub tawm cov ntaub ntawv server los ntawm lub chaw sau ntawv raug cai. Ua li no, nkag mussudo apt nruab openssh-serverthiab ces nias tus yuam sij Sau.
  3. Txij li thaum peb siv lub cim ua ntej sudo (ua ib qho haujlwm rau tus superuser sawv cev), koj yuav tsum sau tus password rau koj tus lej account. Nco ntsoov tias cov cim tsis pom tshwm thaum tawm tswv yim.
  4. Koj yuav tau txais ntawv ceeb toom txog kev rub tawm qee qhov ntim ntawm cov ntawv teev lus, paub meej qhov kev txiav txim los ntawm xaiv D.
  5. Los ntawm lub neej ntawd, cov neeg tau nruab nrog tus neeg rau zaub mov, tab sis nws yuav tsis yog ua kom muaj kev txheeb xyuas nws lub xub ntiag los ntawm kev sim rov nruab nws sivsudo apt-tau nruab openssh-tus thov kev pab.

SSH server yuav muaj rau kev cuam tshuam nrog nws tam sim ntawd tom qab qhov kev vam meej ntxiv ntawm txhua cov ntaub ntawv rau kev ua haujlwm, tab sis nws tseem xav tau teeb tsa kom ntseeg tau tias kev ua haujlwm raug. Peb xav kom koj yuav tsum paub koj tus kheej nrog cov theem hauv qab no.

Kauj Ruam 2: Tshawb Xyuas Kev Ua Haujlwm Zoo

Ua ntej tshaj, peb nco ntsoov tias cov qauv tsis raug siv tau raug, thiab SSH-server teb rau cov lus qhia yooj yim thiab tua lawv kom raug, yog li koj xav tau:

  1. Tua tawm lub console thiab sau ntawv muajsudo systemctl pab sshdntxiv cov server rau Ubuntu startup yog tias qhov no tsis tshwm sim tom qab kev teeb tsa.
  2. Yog tias koj tsis xav tau cov cuab yeej los pib nrog OS, tshem nws tawm ntawm autorun los ntawm kev nkag mussudo systemctl lov tes taw sshd.
  3. Tam sim no cia peb kuaj seb txoj kev sib txuas mus rau lub khoos phis tawm hauv zos tau ua li cas. Thov siv cov lus txibssh localhost(hauv zos yog qhov chaw nyob ntawm koj lub PC hauv cheeb tsam).
  4. Paub meej tias txuas txuas ntxiv los ntawm xaiv yog lawm.
  5. Nyob rau hauv cov ntaub ntawv ntawm kev vam meej rub tawm, koj yuav tau txais kwv yees li ntawm tib cov ntaub ntawv raws li koj pom hauv cov duab hauv qab no. Tshawb xyuas qhov tsim nyog thiab txuas nrog rau qhov chaw nyob0.0.0.0, uas ua raws li lub chaw xaiv chaw network IP rau lwm pab kiag li lawm. Ua li no, nkag mus rau qhov tsim nyog hais kom ua thiab nyem rau ntawm Sau.
  6. Nrog rau txhua qhov kev sib txuas tshiab, nws yuav tsim nyog kom paub meej nws.

Raws li koj tuaj yeem pom, ssh hais kom ua siv txuas rau txhua lub khoos phis tawm. Yog tias koj xav tau txuas rau lwm lub cuab yeej, cia li pib lub davhlau ya nyob twg thiab sau cov lus txib ua hom ntawvssh username @ ip_address.

Kauj ruam 3: Kho cov ntawv configuration

Txhua qhov SSH raws tu qauv tau teeb tsa los ntawm cov ntaub ntawv tshwj xeeb teeb tsa los ntawm kev hloov pauv kab thiab muaj txiaj ntsig. Peb yuav tsis tsom rau tag nrho cov ntsiab lus, ntxiv rau, feem ntau ntawm lawv yog tus neeg ntshiab rau txhua tus neeg siv, peb yuav tsuas qhia qhov kev ua tseem ceeb.

  1. Ua ntej tshaj, khaws ib daim ntawv theej ntawm cov ntawv teeb tsa ua kom muaj qee yam koj tuaj yeem nkag mus lossis kho lub xeev thawj zaug ntawm SSH. Muab cov lo lus txib rau hauv lub consolesudo cp / thiab / ssh / sshd_config /etc/ssh/sshd_config.original.
  2. Tom qab ntawd tus thib ob:sudo chmod a-w /etc/ssh/sshd_config.original.
  3. Lub chaw teeb tsa yog tsim los ntawmsudo vi / thiab / ssh / sshd_configCov. Tom qab nkag mus rau nws, nws yuav tau pib tsim thiab koj yuav pom nws cov ntawv, raws li qhia hauv lub screenshot hauv qab no.
  4. Ntawm no koj tuaj yeem hloov chaw nres nkoj siv, uas yog ib txwm ua zoo tshaj plaws kom ntseeg tau tias muaj kev ruaj ntseg ntawm kev sib txuas, tom qab ntawd tus ID nkag mus hauv tus superuser (PermitRootLogin) tuaj yeem raug xiam thiab qhib kev ua haujlwm los ntawm tus yuam sij (PubkeyAuthentication) tuaj yeem qhib. Tom qab ua tiav ntawm kho, nias lub khawm : (Hloov + hauv Latin layout) thiab ntxiv tsab ntawvwkom txuag kev hloov pauv.
  5. Kev tawm cov ntawv tawm tau ua tiav ib qho, tab sis hloovwyog sivq q.
  6. Nco ntsoov rov qab pib dua tus neeg rau zaub mov ntawm kev ntaus ntawvsudo systemctl rov ssh.
  7. Tom qab hloov chaw nres nkoj nquag, koj yuav tsum kho nws hauv tus neeg thov. Qhov no yog ua los ntawm kev teev tsegssh -p 2100 localhostqhov twg 2100 - tus naj npawb ntawm lub chaw nres nkoj hloov.
  8. Yog tias koj muaj lub foob pob hluav taws tau teeb tsa, nws kuj xav kom hloov chaw:sudo ufw tso cai 2100.
  9. Koj yuav tau txais kev ceeb toom tias txhua txoj cai tau hloov tshiab.

Koj tuaj yeem paub koj tus kheej nrog rau cov tsis dhau los ntawm kev nyeem cov ntawv sau raug. Muaj cov lus qhia los hloov txhua yam khoom siv los pab txiav txim siab uas koj yuav tsum xaiv tus kheej.

Kauj ruam 4: Ntxiv Cov Yuam Sij

Thaum muab cov yuam sij SSH ntxiv, kev tso cai ntawm ob lub khoom siv qhib tsis thas xav tau tus lej zais. Cov txheej txheem txheeb xyuas tau rov ua dua nyob rau hauv cov txheej txheem rau kev nyeem cov lus zais thiab pej xeem.

  1. Qhib lub console thiab tsim tus yuam sij tshiab los ntawm kev nkag musssh-keygen -t dsa, thiab tom qab ntawd qhia cov ntaub ntawv thiab qhia tus password rau kev nkag.
  2. Tom qab ntawd, tus yuam sij pej xeem yuav raug cawm thiab cov duab zais yuav tsim. Ntawm qhov screen koj yuav pom nws txoj kev pom.
  3. Nws tshua tsuas yog luam cov ntawv tsim rau hauv lub computer thib ob txhawm rau rho tawm qhov kev sib txuas ntawm lo lus zais. Siv kev hais kom uassh-copy-id username @ remotehostqhov twg username @ remotehost - Lub npe ntawm tej thaj chaw deb lub computer thiab nws tus IP chaw nyob.

Nws tshua tsuas yog rov qab qhib lub server thiab txheeb xyuas nws txoj haujlwm tseeb los ntawm cov pej xeem thiab cov yuam sij zais cia.

Qhov no ua tiav qhov kev teeb tsa ntawm SSH server thiab nws txoj kev teeb tsa yooj yim. Yog tias koj sau tag nrho cov lus txib kom raug, tsis muaj qhov yuam kev yuav tsum tshwm sim thaum ua haujlwm. Thaum muaj teeb meem kev sib txuas tom qab teeb tsa, sim tshem SSH ntawm kev pib kom daws qhov teeb meem (nyeem txog nws hauv Kauj ruam 2).

Pin
Send
Share
Send