Openssh client config: Difference between revisions

From wikinotes
 
No edit summary
Line 1: Line 1:
= Documentation =
<blockquote>
{| class="wikitable"
|-
| <code>man ssh_config</code> || https://man.archlinux.org/man/core/openssh/ssh_config.5.en
|-
|}
</blockquote><!-- Documentation -->
= Locations =
= Locations =
<blockquote>
<blockquote>

Revision as of 14:45, 9 July 2022

Documentation

man ssh_config https://man.archlinux.org/man/core/openssh/ssh_config.5.en

Locations

Unix

/etc/ssh/ssh_config global config
~/.ssh/config user config
~/.ssh/{key}.pub public ssh key
~/.ssh/{key} private ssh key

Windows

SSH keys

SSH keys are a secure method of passwordless SSH authentication.
You can create a keypair using various algorithms, ed2559 is currently considered the most secure.

Generate SSH keys

ssh-keygen -t ed25519
chmod 600 ~/.ssh/*

Authorize SSH keys

Append your public key to a new line in ~/.ssh/authorized_keys to allow SSHing ing as that user on that server.

SSH is picky about permissions.

mkdir ~/.ssh
chmod 700 ~/.ssh

touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
cat id_ed25519 >> ~/.ssh/authorized_keys

Permissions

On windows, permissions are tricky.

icacls .\private.key /inheritance:r
icacls .\private.key /grant:r "%username%":"(R)"

# if you've broken permissions, reset using
gsudo icacls .\private.key /T /Q /C /RESET

SSH config

# ~/.ssh/config
Host deathstar
   User          vaderd
   Port          2222
   HostName      1.1.1.1
   IdentityFile  ~/.ssh/impreials

# .. can add multiple entries
# equivalent to:
#   ssh -p 2222 vaderd@1.1.1.1 -i ~/.ssh/imperials
ssh deathstar

# use ssh-config for git
git clone ssh://deathstar:/home/vaderd/repo