Skip to main content
Creating a Cloud Server and Acessing with SSH Keys Using Windows Powershell on Hetzner
- Make sure you have Powershell version 5.1 or better
- Open Powershell, type: $PSVersionTable.PSVersion
- Install update if you don't have it: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows
- Make sure you have the SSH service installed
- Type: ssh
- If you get an error, install ssh: https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=powershell
- Create an SSH key (from: https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement)
- Type: ssh-keygen -t ed25519 ('ed25519 is the type of key you're generating)
- This will produce output:
- Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\username/.ssh/id_ed25519):
- Type enter to accept the default name or type a different filename and type enter
- You will be asked to type a passphrase. Enter a passphrase if you wish, or just type Enter for no passphrase
- This will generate a private key and a public (.pub) key as follows:
- Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 6/3/2021 2:55 PM 464 ed25519
-a---- 6/3/2021 2:55 PM 103 ed25519.pub
- Make your Powershell SSH agent start automatically (from: https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement) (you probably only have to do this once, and it might not work)
- Make sure you're running PowerShell as an administrator
- Set the startup type. Type: Get-Service ssh-agent | Set-Service -StartupType Automatic
- Start the service. Type: Start-Service ssh-agent
- Load your key: ssh-add $env:USERPROFILE\.ssh\id_ed25519
- Note: $env:USERPROFILE is just your home directory (eg., for me, C:\user\steph)
- So I just CD right into the .ssh directory: cd C:\user\steph\.ssh
- Then I just just type this: ssh-add id_ed25519
- Create a new server on Hetzner
- Create an account on Hetzner
- Open the Clod console: https://console.hetzner.cloud/projects
- Create a new Project and give it a name
- Click on the 'Add Server' button
- Select your configuration from the options provided. I used:
- Location: Nuremberg
- Image: Ubuntu 22.04
- Type: Shared vCPU
- Configuration: CX31 ( 2 CPUs, 8 GB RAM, 80 GB Disc, etc)
- Networking: both IPv4 and IPv6
- SSH Keys:
- Click 'Add SSH Key'
- Open your SSH public key in a text editor (in this case, C:\user\steph\.ssh\id_ed25519.pub)
- Copy all the text
- Paste the text into the form where it says: SSH key
- It should automatically assign a name from the public key (it's aty the very end of the text you copied)
- Click 'Add SSH Key'
- Create Volume: 40 gigabites
- Don't select Firewall (do that manually later)
- Select Backup
- Don't select placement groups, label or cloud config
- Enter an easy-to remember name
- Click 'Create and Buy Now' (lower Right)
- Associate the key with the server
- Get the IP address for the server (It's at the top of the page) eg. 195.201.216.204
- Log in to your server: ssh -i id_ed25519 root@195.201.216.204
- Note: -i specifies the name of your key you're using.
- (If this doesn't work, try typing: Start-Service ssh-agent )
- Enjoy!
Comments
Post a Comment
Your comments will be moderated. Sorry, but it's not a nice world out there.