# ssh

## 1. keys

Keep your public and private keys in a directory. Your ssh agent will have to know about your private key. You can give your public key to someone, e.g. github. Then, to authenticate yourself, you will sign using your private key.

## 2. public key encyrption

In RSA, you have \(d\), \(e\), and \(n\) such that \((m^e)^d \equiv m \mod n\) for every \(0 < m < n\). Then, \(e\) and \(n\) are the public keys and \(d\) is the private key.

You can give out \(e\) to anyone. And they can encrypt a message that only you, holding \(d\), will be able to decrypt. It's assumed that it's hard to find \(d\) given \(m^e\), \(n\), and \(e\).

When using someone elses public key, you can *sign* the message using your private key. That is you can, along with the message, also send a *signature* – the message encrypted using your private key \(d\). Then, the recipient will decrypt using your public key \(e\). If the result is the original message, then they know that you are the holder of the private key.

## 3. Start agent and add keys

`eval "$(ssh-agent -s)"`

to start ssh agent`ssh-add ~/.ssh/github_keys/id_rsa`

(note that ssh keys live in AFS)