---
title: generate RSA SSH keys
tags: common
---
1. Check existing keys
`$ cd ~/.ssh`
`$ ls`
`$ cat ~/.ssh/id_rsa.pub`
:::info
Note for **Windows 10**
* Just start from step 2
:::
2. `$ ssh-keygen -t rsa -b 4096 -C "your comment"`
ex `$ ssh-keygen -t rsa -b 4096 -C "msi-laptop"`
ed25519 `ssh-keygen -t ed25519 -C "your comment"`
:::info
Note for **Windows 10**
* It will be saved in the default location (c/Users/you/.ssh/id_rsa)
:::

3. Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
/** Leave it empty, just hit enter **/
4. `$ eval "$(ssh-agent -s)"`
`$ ssh-add <path to private SSH key>`
ex. `$ ssh-add ~/.ssh/id_rsa`
/** Add to agent **/
5. `$ cat ~/.ssh/id_rsa.pub`
Add SSH Keys on GitHub/ GitLab/ Bitbucket
then...check the keys
-------------------------------------
```ssh -T git@github.com```
```
Hi wolfzxcv! You've successfully authenticated, but GitHub does not provide shell access.
```
--------------------------------------
```ssh -T git@gitlab.com```
```
Welcome to GitLab, @neja.chou!
```
---
`$ ssh -T git@bitbucket.org`
```
logged in as nejachou
You can use git or hg to connect to Bitbucket. Shell access is disabled
```
---
Might have to install this, in order to clone from remote sites properly
`sudo apt install ssh-askpass`
---
### Login from A(you) to B(server) without password
* 放在使用者資料夾下的 .ssh 資料夾中,其中 id_rsa 為私鑰、id_rsa.pub 則為公鑰
* 1. Check existing keys
`$ cd ~/.ssh`
`$ ls`
`$ cat ~/.ssh/id_rsa.pub`
* 2. Upload the key
* Point to the path where id_rsa.pub locates `$ cd ~/.ssh`
* Copy the key to the server you wanna connect `$ ssh-copy-id [B's user]@[B's host]`
ex. `ssh-copy-id pmduser@10.20.30.215`
* Now you can login to B without password