Birmingham mumbai


Copying your public key to a remote server



Download 15,21 Mb.
Pdf ko'rish
bet352/482
Sana13.01.2022
Hajmi15,21 Mb.
#355107
1   ...   348   349   350   351   352   353   354   355   ...   482
Bog'liq
Mastering Ubuntu Server Gain expertise in the art of deploying, configuring, managing, and troubleshooting Ubuntu Server by Jay LaCroix (z-lib.org)

Copying your public key to a remote server
To actually transmit your public key to a target server, we can use the 
ssh-copy-id
 
command, as I'm doing in the following example command:
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.1.150


Connecting to Networks
[
 268 
]
With that command, replace the IP address with the actual IP address, or with the 
hostname
 of the target server. You'll be asked to log in via password first, and then 
your key will be copied over. From that point on, you'll log in via your key, falling 
back to being asked for your password if, for some reason, your key relationship is 
broken. Here's an example of what this process looks like, if I were to work through 
the process of copying my key to a server named 
myserver.mycompany.org
:
Figure 10.10: Using the ssh-copy-id command to copy a public key to a server
So, what exactly did the 
ssh-copy-id
 command do? Where is your public key copied 
to, exactly? What happens with this command is that on the target server, a 
.ssh
 
directory is created in your 
home
 directory on the target server if it didn't already 
exist. Inside that directory, a file named 
authorized_keys
 is created if it wasn't 
already present. The contents of 
~/.ssh/id_rsa.pub
 on your machine are copied 
into the 
~/.ssh/authorized_keys
 file on the target server. With each additional key 
you add (for example, you connect to that server from multiple machines), the key is 
added to the end of the 
authorized_keys
 file, one per line.
When you connect to a server that you have set up a key relationship with by adding 
your public key, SSH checks the contents of the 
~/.ssh/authorized_keys
 file on 
that server, looking for a key that mathematically matches the private key (
~/.ssh/
id_rsa
) on your machine. If the two keys are an appropriate match, you are allowed 
access. If you set up a passphrase, you'll be asked to enter it in order to open your 
public key.
Using the 
ssh-copy-id
 command is merely a matter of 
convenience, there's nothing stopping you from copying the 
contents of your 
id_rsa.pub
 file and manually pasting it into 
the 
authorized_keys
 file of the target server. That method will 
actually work just fine as well.


Chapter 10

Download 15,21 Mb.

Do'stlaringiz bilan baham:
1   ...   348   349   350   351   352   353   354   355   ...   482




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish