# SSH keys :key: 1. Create an SSH key pair with the following command: ```bash ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519_key -C "MyNewKey" ``` 2. Add your newly generated Ed25519 key to an **SSH agent**: ```bash ssh-add ~/.ssh/id_ed25519_key ``` 3. Copy the public key to Rackham or other server. ```bash ssh-copy-id -i .ssh/id_ed25519_key.pub rackham.uppmax.uu.se ``` 4. Connect ```bash ssh username@rackham.uppmax.uu.se ``` ## On Bianca - Add the content of your public key `id_ed25519_key.pub` to `$HOME/.ssh/authorized_keys`. **You can not** use the same command `ssh-copy` as in the case for Rackham i.e. you have to manually bring the key on Bianca. If you paste it, **make sure it is in one line**, not wrapped/split over multiple lines. - **Make sure the permissions look something like this**. ```bash ls -ld .ssh drwx--S--- 2 user user 4096 May 7 2019 .ssh ls -l .ssh total 1 -rw-r----- 1 user user 743 May 7 2019 authorized_keys ``` - Connect to Bianca (*it is critical to use **SSH agent** in this case, see above*) ```bash ssh -A user-sensXXXXX@bianca.uppmax.uu.se ``` - To debug, run with `-vv` ```bash ... debug1: Requesting authentication agent forwarding. debug2: channel 1: request auth-agent-req@openssh.com confirm 0 ... debug1: client_input_channel_open: ctype auth-agent@openssh.com rchan 2 win 65536 max 16384 debug1: client_request_agent: bound agent to hostkey debug2: fd 8 setting O_NONBLOCK debug1: channel 2: new [authentication agent connection] debug1: confirm auth-agent@openssh.com Last login: Tue Jul 11 18:44:21 2023 from 172.18.144.254 _ _ ____ ____ __ __ _ __ __ | | | | _ \| _ \| \/ | / \ \ \/ / | System: sens2017625-bianca | | | | |_) | |_) | |\/| | / _ \ \ / | User: user | |_| | __/| __/| | | |/ ___ \ / \ | \___/|_| |_| |_| |_/_/ \_\/_/\_\ | ############################################################################### ``` ## WSL2 under Windows{10,11} Here as a neat way to get persistent key-manger in WSL2 - credits: original [source](https://esc.sh/blog/ssh-agent-windows10-wsl2/). ```bash sudo apt-get install keychain ``` Replace `XXXX` with the output of `hostname` command on the command line. ```bash /usr/bin/keychain -q --nogui $HOME/.ssh/id_ed25519_key source $HOME/.keychain/XXXX-sh ``` Remove `-q` to get some information if you want ```bash * keychain 2.8.5 ~ http://www.funtoo.org * Found existing ssh-agent: 4487 * Known ssh key: /home/user/.ssh/id_ed25519_key ``` First time you login, you will be asked for the password and the key wil be handled by the key-manager. Check with ```bash ssh-add -l 256 SHA256:wLJvQOM.... ....cTTtiU MyNewKey (ED25519) ``` ## MobaXterm In `MobaXterm` you can use the internal `MobAgent` or/and the `Peagent` from the `PuTTy` tools. ![](https://hackmd.io/_uploads/HyDznkLkp.png) ## OPTIONAL: SSH config Example `$HOME/.ssh/config` file to make your work easier. ```bash Host rackham User username HostName rackham.uppmax.uu.se ServerAliveInterval 240 ServerAliveCountMax 2 # Default settings #======================================= Host * ForwardAgent no ForwardX11 yes ForwardX11Trusted yes ServerAliveInterval 120 #======================================= ``` Now ```bash # without config ssh -Y username@rackham.uppmax.uu.se # with config ssh rackham ``` ```bash # without config scp local_file username@rackham.uppmax.uu.se:remote_folder/ # with config scp local_file rackham:remote_folder/ rsync ... sftp ... ``` ## Contacts: - [Pavlin Mitev](https://katalog.uu.se/profile/?id=N3-1425) - [UPPMAX](https://www.uppmax.uu.se/) - [AE@UPPMAX - related documentation](/8sqXISVRRquPDSw9o1DizQ) ![](https://live.webb.uu.se/digitalAssets/207/c_207717-l_3-k_bg-city.png) ###### tags: `UPPMAX`, `ssh-key`