This commit is contained in:
louiscklaw
2025-01-31 19:24:01 +08:00
parent 1d3678b2fb
commit 4afadb4bfd
54 changed files with 2604 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
<h1 style="text-align: center;">SSH Key Configuration Guide</h1>
This guide will walk you through the process of configuration of SSH key for remote SSH connections to servers on both Windows and Linux. Fast-connecting to a sever using SSH public key authentication is a SSH connection trick that makes it easy to connect to a remote server.
## Generating SSH Keys
### Windows
#### Step 1: Open Powershell Bash
Open the Powershell terminal to prepare for SSH key generation.
#### Step 2: Generate SSH Keys
In the Powershell terminal, use the following command to generate SSH keys:
```bash
# In powershell bash
ssh-keygen
```
Save it by default, the system will save the keys to [your home directory]/.ssh/id_rsa. Unless you are an expert you should use the default option and press Enter.
#### Step 3: View SSH Keys
To view the generated SSH keys, run the following command:
```bash
# In powershell bash
cat ~/.ssh/id_rsa.pub
```
Copy the displayed key and configure it on your server.
### Linux-like systems
#### Step 1: Open Terminal
Open the terminal to prepare for SSH key generation.
#### Step 2: Generate SSH Keys
In the terminal, use the following command to generate SSH keys:
```bash
# In termianl
ssh-keygen
```
Follow the prompts to input the file save path and a passphrase. Generally, you can accept the default values by pressing Enter.
#### Step 3: View SSH Keys
To view the generated SSH keys, run the following command:
```bash
# In termianl
cat ~/.ssh/id_rsa.pub
```
Copy the displayed key and configure it on your server.
## Server Configuration
On your Azure instance/server which your code running on, add the SSH publish key you generated to the `~/.ssh/authorized_keys` file to allow remote SSH access. Ensure that your server has SSH access properly configured.
If you don't have the `authorized_keys` file under the `~/.ssh/`, just create a blank one:
```bash
# In the server terminal, use the following command
touch ~/.ssh/authorized_keys
```
On your own PC, write the alias of the server in the `~/.ssh/config` file:
![](md_img/ssh_config.png)
```bash
Host elec3120us # the alias for server
HostName 20.38.43.192 # server IP address
User elec3120 # server usrname
```
You have now successfully generated SSH keys and are ready for remote SSH connections to your server by typing the following to connect to server _elec3120@20.38.43.192_:
```bash
ssh elec3120us
```
We hope this guide is helpful!