# SSH Key and Config
Why use SSH keys?
* Login to the remote server without entering a password
Why use SSH config?
* Simplify the SSH process with shorter commands
:::success
Let's open your terminal or PowerShell in your computer before we start.
:::
### 1. Create SSH key
Use the following command to create SSH key.
```
ssh-keygen
```
After running the command, you'll see the following output:
```
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cial1/.ssh/id_rsa):
```
Press `Enter` to use the default path.
```
Enter passphrase (empty for no passphrase):
```
Press `Enter` again to ignore passphrase.
```
Enter same passphrase again:
```
Press `Enter` again to confirm ignoring passphrase.

(The SSH Key generated by each individual is unique.)
### 2. Add public key to remote server
First, we need to enter `.ssh` directory
```
cd ~/.ssh
```
If you use `ls` command, you will see `id_rsa.pub`, that is your SSH public key.
Use the following command to copy your SSH public key to the remote server.
```
scp id_rsa.pub [username]@[ip address]:~/.ssh/authorized_keys
```
:::warning
Make sure to replace `[username]` with your actual username and replace `[ip address]` with the server's actual ip address.
For example :
```
scp id_rsa.pub F74114710@140.116.246.48:~/.ssh/authorized_keys
```
:::
After running this command, you may need to enter your password for server authentication.
:::info
Finally, you can SSH to the server without typing a password.🎉
```
ssh [username]@[ip address]
```
:::
### 3. Setup SSH config
Create a file named `config` at `~/.ssh/config`
```
vim ~/.ssh/config
```
:::success
If your computer runs on Windows and does not have `Vim` installed, you can use the following commands(in PowerShell):
```
New-Item ~/.ssh/config
~/.ssh/config
```
Then choose the editor you like.
:::
Paste the following text inside the `config` file
```
HOST pd1
Hostname [ip address]
User [username]
```
:::warning
Make sure to replace `[ip address]` with the server's actual ip address and replace `[username]` with your actual username.
For example:
```
HOST pd1
Hostname 140.116.246.48
User F74114710
```
:::
Remember to save the file.
------------------------
Now, you can use the following command to connect to the server
```
ssh pd1
```

</br>
<p class="text-center"><font size=5>Congratulation!🎉</font></p>
<!--
[Interface]
PrivateKey = OJKknnJs12x8ESCCSCgKDJUSLY1gMGH+rzT+vyJBmUI=
Address = 10.19.49.57/32
DNS = 172.24.157.208
[Peer]
PublicKey = beqEMF9PiU+mpKVK/C2DGTXX1iEFdTkwjo9cylfxthY=
PresharedKey = LdpWyHggphCBMbKtpJrq836v9J3D14+29v3hVBSD73U=
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = wireguard.ccns.io:51820
-->