Cov txheej txheem:

Ruaj ntseg SSH / SCP Kev Sib Txuas Los Ntawm Raspberry Pi rau Cloud Server rau Backups thiab Hloov Kho: 3 Cov Kauj Ruam
Ruaj ntseg SSH / SCP Kev Sib Txuas Los Ntawm Raspberry Pi rau Cloud Server rau Backups thiab Hloov Kho: 3 Cov Kauj Ruam

Video: Ruaj ntseg SSH / SCP Kev Sib Txuas Los Ntawm Raspberry Pi rau Cloud Server rau Backups thiab Hloov Kho: 3 Cov Kauj Ruam

Video: Ruaj ntseg SSH / SCP Kev Sib Txuas Los Ntawm Raspberry Pi rau Cloud Server rau Backups thiab Hloov Kho: 3 Cov Kauj Ruam
Video: Клонирование репозитория GitHub с помощью Laravel Sail 2024, Kaum ib hlis
Anonim
Ruaj ntseg SSH / SCP Kev Sib Txuas Los ntawm Raspberry Pi rau Cloud Server rau Backups thiab hloov tshiab
Ruaj ntseg SSH / SCP Kev Sib Txuas Los ntawm Raspberry Pi rau Cloud Server rau Backups thiab hloov tshiab

Lub hom phiaj ntawm cov lus qhia no yog los qhia koj yuav ua li cas txuas tau zoo thiab nyab xeeb los ntawm koj li Raspberry Pi mus rau lub server huab nyob deb (thiab hloov pauv) txhawm rau txhawm rau nqa tawm rov qab thiab hloov tshiab thiab lwm yam. Ua qhov no, koj siv SSH qhov tseem ceeb khub uas obviate qhov xav tau kom nco qab tus password thiab muab kev sib txuas ruaj ntseg rau koj.

(CAVEAT - Tsis txhob sim qhov no yog tias koj tsis muaj peev xwm teeb tsa Linux tso cai txwv tsis pub koj yuav ua rau koj lub tshuab muaj kev phom sij ntau los ntawm kev nyiag los ntawm hackers.)

Yuav tsum muaj

1. Raspberry Pi nrog kab hais kom ua interface (CLI) zoo li koj yuav pom ntawm Putty.

2. Nkag mus rau lub server huab nyob deb uas tuav los ntawm hais OVH lossis DigitalOcean, nrog CLI.

3. Lub Windows laptop lossis PC nrog Putty thiab PuttyGen teeb tsa.

Kev xav

1. Koj muaj qee qhov kev paub txog Linux cov lus txib

2. Koj tuaj yeem nkag mus rau koj cov neeg rau zaub mov nyob deb uas siv cov txheej txheem kev ua haujlwm, xws li FTP.

3. Koj yuav tau teeb tsa PuttyGen ua ntej ntawm koj lub PC Windows

Cov kauj ruam

Hauv qhov xaus, - Saib Daim Duab 1

a) Ntawm koj lub Windows PC, tsim Cov Ntaub Ntawv PPK ntiag tug siv PuttyGen

b) Ntawm koj lub Windows PC, tsim cov ntaub ntawv PPK rau pej xeem siv PuttyGen (qhov no tau ua tiav hauv qib a)

b) Ntawm koj lub Windows PC, theej Public Key los ntawm koj lub Windows PC mus rau lub server huab nyob deb

d) Ntawm koj lub Windows PC, hloov Cov Ntaub Ntawv PPK Ntiag Tug mus rau qhov qhib OpenSSH siv PuttyGen

e) Luam qhov OpenSSH qhov tseem ceeb los ntawm koj lub PC Windows mus rau Raspberry Pi

f) Kuaj tawm kev nkag mus thiab xa cov ntaub ntawv los ntawm Raspberry Pi mus rau koj lub server server

Kauj Ruam 1: A) Tsim Tus Kheej PPK Cov Ntaub Ntawv, B) Tsim Tus Kheej Tus Kheej thiab C) Luam nws mus rau Chaw Taws Teeb

A) Tsim Tus Kheej PPK Cov Ntaub Ntawv, B) Tsim Tus Zej Zog Tseem Ceeb thiab C) Luam nws mus rau Cov Chaw Taws Teeb
A) Tsim Tus Kheej PPK Cov Ntaub Ntawv, B) Tsim Tus Zej Zog Tseem Ceeb thiab C) Luam nws mus rau Cov Chaw Taws Teeb
A) Tsim Tus Kheej PPK Cov Ntaub Ntawv, B) Tsim Tus Zej Zog Tseem Ceeb thiab C) Luam nws mus rau Cov Chaw Taws Teeb
A) Tsim Tus Kheej PPK Cov Ntaub Ntawv, B) Tsim Tus Zej Zog Tseem Ceeb thiab C) Luam nws mus rau Cov Chaw Taws Teeb

Txhawm rau tsim cov ntaub ntawv PPK ntiag tug, qhib PuttyGen ntawm koj lub PC Windows. Koj tuaj yeem nkag mus rau PuttyGen los ntawm txoj nyem rau ntawm lub cim putty ntawm Windows taskbar. Los ntawm cov ntawv qhia zaub mov PuttyGen, xaiv qhov tseem ceeb tom qab ntawd tsim tus lej tseem ceeb, xaiv qhov xaiv SSH2 -RSA qhov tseem ceeb. Koj yuav raug hais kom teeb tus lej nkag thaum koj tsim tus yuam sij ntiag tug, thiab yog tias koj teeb tus lej nkag, koj yuav raug nug rau nws thaum ua haujlwm yav tom ntej. Tom qab ntawd koj yuav pom tus yuam sij pej xeem hauv lub qhov rai pane raws li qhia hauv daim duab 2.

Tom ntej no, cia peb hloov tus yuam sij pej xeem mus rau lub server huab nyob deb. Qhib kev sib tham Putty rau lub server huab huab nyob deb siv Putty. Cia peb hais tias koj tau nkag rau hauv li remoteuser1 tom qab ntawd ua cov hauv qab no ntawm cov chaw taws teeb huab server CLI

cd /tsev /remoteuser1 (yog tias tsis muaj lawm) mkdir.ssh

nano.ssh/tso cai_key (Koj yuav pom lub vijtsam npliag - muab tus yuam sij rau pej xeem pom hauv daim duab 2 ces khaws thiab kaw cov ntawv no)

hwb 0700

chmod 0600 /home/remoteuser1/.ssh/authorized_keys

Kauj Ruam 2: D) Hloov Cov Ntaub Ntawv PPK ntiag tug rau OpenSSH Key thiab E) Luam nws mus rau Raspberry Pi

Txhawm rau hloov tus yuam sij ntiag tug rau OpenSSH, qhib PuttyGen thiab tom qab ntawd qhib tus yuam sij ntiag tug uas koj tau tsim ua ntej - mus rau Kev Sib Hloov pauv ntawm cov ntawv qhia zaub mov ces xaiv Export OpenSSH qhov tseem ceeb - thov xyuas kom cov ntaub ntawv koj tsim muaj cov ntaub ntawv.key. Txuag nws ib qho chaw nyab xeeb tom qab ntawd qhib lub rooj sib tham tso rau hauv koj li Raspberry Pi. Luam cov ntaub ntawv tseem ceeb rau hauv phau ntawv teev npe tsev ntawm Raspberry Pi ntawm tus neeg siv nyiaj koj tau siv los nkag rau Raspberry Pi. Hais tus yuam sij hu ua pitobot.key ces ua raws cov theem hauv qab no:

cd /home /pib

sudo mv pitobot.key/tsev/pi/

sudo chmod 600 pitobot.key

Tam sim no koj tau npaj los sim yog tias koj kev teeb tsa ua tiav - Ib zaug ntxiv, qhov no tau ua tiav los ntawm Pi. Nco ntsoov, remoteuser1 yog tus as khauj ntawm lub server huab nyob deb uas nws cov npe hauv tsev koj tau khaws tus yuam sij pej xeem, thiab ipaddress yog ipaddress ntawm lub server huab nyob deb.

Thawj zaug los ntawm Raspberry Pi, cia nkag mus rau lub server huab huab nyob deb siv Putty. Ntaus cov lus txib hauv qab no ntawm Raspberry PI CLI. (Yog tias koj tau teeb tsa kab lus thaum koj tsim tus yuam sij ntiag tug, koj yuav raug nug tam sim no.)

sudo ssh -i /home/pi/pitobot.key remoteuser1@ipaddress

Qhov no yuav nkag mus rau koj rau hauv CLI ntawm cov chaw taws teeb huab server ntawm cov npe hauv tsev ntawm remoteuser1. Los ntawm kev ntaus 'tawm; koj yuav rov qab mus rau CLI ntawm koj li Raspberry Pi.

Tom ntej no, sim hloov cov ntaub ntawv los ntawm cov chaw taws teeb huab server mus rau Raspberry Pi. Siv cov lus txib hauv qab no: (Ib zaug ntxiv, yog tias koj tau teeb tsa kab lus thaum koj tsim tus yuam sij ntiag tug, koj yuav raug nug tam sim no.)

sudo scp -i /home/pi/pitobot.key remoteuser1@ipaddress: //var/www/html/*.*/tsev/pi/

Qhov no yuav hloov tag nrho cov ntaub ntawv los ntawm/var/www/html/nplaub tshev ntawm cov chaw taws teeb server mus rau/home/pi/folder ntawm koj Raspberry Pi. (Cov nyuv tseem ceeb heev) Koj tuaj yeem hloov pauv qhov kev txiav txim ntawm cov lus txib thiab hloov cov ntaub ntawv los ntawm Pi mus rau lub server deb.

Kauj Ruam 3: Kev Nyab Xeeb Kev Nyab Xeeb

Whilst tus SSH tus khub tseem ceeb mus kom ze rau kev nyab xeeb, xav txog cov hauv qab no:

1. Nrog SSH qhov tseem ceeb ua haujlwm qhib, koj yuav tsum txiav txim siab tshem tawm lub peev xwm rau cov neeg siv nkag mus ncaj qha rau cov neeg rau zaub mov nyob deb (Koj tseem tuaj yeem nkag mus rau koj cov servers siv tus lej tseem ceeb Putty ntawm Windows siv tib tus lej tseem ceeb, thiab koj tseem tuaj yeem txiav txim siab xiam oob qhab. nkag rau hauv koj tus Pi ib yam nkaus). Ceev faj yog tias koj xaiv ua qhov no thiab tsis txhob ua qhov kev cuam tshuam loj. Txhawm rau ua qhov no, koj yuav tsum xiam ob peb kev teeb tsa hauv ssh teeb tsa cov ntaub ntawv. Ua tib zoo ua qhov no. Cov lus txib yog

nano/etc/ssh/sshd_config

Thiab hauv cov ntawv ua cov kev hloov hauv qab no

PasswordAuthentication no

UsePAM tsis muaj

Txuag, tawm ces rov pib dua SSH los ntawm systemctl rov pib ssh (Qhov no yog rau Debian. Nws yuav txawv ntawm Linux sib txawv)

2) Khaws tag nrho koj cov yuam sij kom ruaj ntseg yog li koj yuav muaj kev cuam tshuam cov ntaub ntawv lossis tsis nkag mus rau koj li servers. Kuv pom zoo kom lawv nyob hauv lub vault ruaj ntseg xws li bitwarden.com, thiab txwv kev nkag mus rau nws los ntawm koj txoj cai tswj kev nkag mus.

3) Kev siv tus lej dhau los txhim kho kev nyab xeeb tab sis nws tuaj yeem ua rau automation ntawm cron cov haujlwm thiab lwm yam nyuaj dua. Qhov kev txiav txim siab siv qhov no thiab lwm yam yuav tsum tau txiav txim siab los ntawm kev ntsuas kev pheej hmoo, piv txwv li, yog tias koj tab tom ua cov ntaub ntawv tus kheej ces koj xav tau kev tswj hwm ntau dua / feem.

Pom zoo: