main-site

Main site for niliara.net
git clone git://niliara.net/main-site
Log | Files | Refs

ssh-into-server.md (1191B)


      1 +++
      2 title = 'Using SSH keys to connect to a server'
      3 date = 2025-06-17T23:41:29+02:00
      4 draft = false
      5 +++
      6 
      7 This is a simple one,
      8 but one I keep forgetting.
      9 
     10 ## Generating keys
     11 SSH keys can be generated with the ssh-keygen command.
     12 The key type can be specified of key using the -t argument
     13 followed by the name of the type
     14 [ ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa ].
     15 
     16 From inside the ~/.ssh/ folder, generate an ed25519 key:
     17 
     18 ```bash
     19 ssh-keygen -t ed25519
     20 ```
     21 
     22 ## Configuring ssh to use a key
     23 Running ssh-keygen creates a private key and a public key (.pub).
     24 The ~/.ssh/config file can be edited in order to tell ssh
     25 which private key to use for each host:
     26 
     27 ```txt
     28 Host <<ip/link to your server>>
     29     IdentityFile ~/.ssh/<<myprivatekey>>
     30 ```
     31 
     32 In this example, ssh will use the private key at `~/.ssh/niliaranet file`
     33 when connecting to niliara.net:
     34 
     35 ```txt
     36 Host niliara.net
     37     IdentityFile ~/.ssh/niliaranet
     38 ```
     39 
     40 ## Authorizing keys
     41 The server should recognise the client after
     42 adding the contents of the public key (.pub)
     43 in a new line inside the server's `~/.ssh/authorized_keys` file.
     44 
     45 Once that's done,
     46 the server should allow access to the client
     47 without prompting for a password.