Skip to content

Latest commit

 

History

History
77 lines (50 loc) · 2.24 KB

ssh-keys.md

File metadata and controls

77 lines (50 loc) · 2.24 KB

SSH Keys

Requirements

#how-to-ssh-into-a-server

#basic-terminal-commands

bitwarden.md

SSH keys explained

SSH keys contain 2 pieces, a public key and a private key.

The public key is installed on whatever hardware you wish to SSH into. The private key is installed on the machine you will SSH from.

How to install the Public Key

Ubuntu

  1. SSH into the server and run the below command to elevate to Root user, input the password you used to log in

    su -i
  2. Run the below commands\

    mkdir -p ~/.ssh
    echo ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDhKliloNg32f9J8xtnLi0wal4FVnTYkNNQRhqTdPNcT [email protected] >> ~/.ssh/authorized_keys
    chmod -R go= ~/.ssh

Windows

  1. Log into the server as an administrator

  2. Open Powershell as administrator and run the below command\

    echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDhKliloNg32f9J8xtnLi0wal4FVnTYkNNQRhqTdPNcT [email protected]" | Out-File -filepath $ENV:userprofile\.ssh\id_rsa.pub -Force -verbose

How to install the Private Key

Ubuntu

  1. SSH into the server and SU into the Root account

  2. Run the below commands

    mkdir -p ~/.ssh/
    nano ~/.ssh/id_rsa
  3. In the text editor, copy and paste the contents of the Private Key and save

  4. Run the below commands to make the key usable

    chmod 700 ~/.ssh/
    chmod 600 ~/.ssh/id_rsa

Windows

  1. Log into the server as an administrator

  2. Open Powershell as administrator and run the below command, putting the contents of the private key between the ""

    $privkey = ""
  3. Run the below command to output the private key into the keystore

    echo $privkey | Out-File -filepath $ENV:userprofile.ssh\id_rsa -Force -verbose VERBOSE: Performing the operation "Output to File" on target "C:\Users\x.ssh\id_rsa"