Quick Start Guide Setting up SSH Key Authentication on a rootserver

vs2-free-users

Active Member
Joined
Jun 8, 2023
Messages
195
Reaction score
94
Credits
1,310
Quick Start Guide Setting up SSH Key Authentication on a rootserver


- You create an SSH key on the local computer

Code:
ssh-keygen -b [Key strength] -t [Key type]


Example:

ssh-keygen -b 4096 -t rsa


- Next you copy your public key to your server

Code:
scp ~/.ssh/id_[Key type].pub [Benutzer]@[Host]:


Example:

scp ~/.ssh/id_rsa.pub [email protected]:


- Next you log in to the server

Code:
ssh [User]@[Host]


Example:

ssh [email protected]


- Now create the SSH directory where the key should be placed

Code:
mkdir -p ~/.ssh/
- Now we create the key itself on the server. If the file already exists, it is simply attached.

Code:
cat ~/id_[Typ].pub >> ~/.ssh/authorized_keys


Example:

cat ~/id_rsa.pub >> ~/.ssh/authorized_keys

- In the next step we delete the uploaded file

Code:
rm -f ~/id_[Key type].pub


Example:

rm -f ~/id_rsa.pub


- Now we set the correct rights otherwise there are sometimes problems

Code:
chmod 0600 ~/.ssh/authorized_keys

chmod 0700 ~/.ssh/


- Now we log out

Code:
exit


- And log in again for verification (no password should be requested now)

Code:
ssh [User]@[Host]


Example:

ssh [email protected]
 



Staff online

Members online


Top