ssh commands
ssh creation
ssh key should be in /home/.ssh folder
to generate ssh key-
ssh-keygen
the command will ask you the ...
For further actions, you may consider blocking this person and/or reporting abuse
An easier method for copying your public key to a remote host is to use the
ssh-copy-id
command.Also, if you have multiple SSH keys on your keyring, you can create scenarios where the git-remote will give you a "
too many authentication failures
" error due to the ssh-agent presenting the wrong key(s) prior to the correct key.Using the SSH config file (~/.ssh/config) can come in handy here.
Specify the remote server you are connecting to using the
Host
statement.Within the host statement you can specify the options that differ from the defaults for that host including but not limited to username and identity.
Then when you connect to the example.com server it will use the options you have specified. On some OSes this also provides auto-completion for the SSH command.
The SSH Config Man page has all the options you can specify linux.die.net/man/5/ssh_config
I do second
ssh-copy-id
. Got to know about it few weeks ago and it's such a helper!You should consider using modern ECDSA SSH keys instead of the old RSA keys. They are more secure and supported on all modern systems.
Details about ECDSA and how to generate them can be found in my article.
If you don't want to read a whole article to figure out how to generate this type of key, simply add
-t ecdsa
to thessh-keygen
command. The why in the article, though, is still a good read.Ackchually, Ed25519 is now the go-to recommended algorithm
You should not use
sudo
when modifying authorised keys. If the file does not already exist, it will set the wrong permissions. Authorised keys is a strictly user file and should only ever be accessed by the user that owns it. Overuse ofsudo
is a dangerous trend that should not be encouraged.Nice work..
I do not use ssh-agent and when using 2 GitHub accounts I use the GIT_SSH_COMMAND variable to specify the key to use. Not sure of this is right or the best way to do it, but it has been useful to me so far
Very useful content π
Thank you for sharing and clearing the concepts of SSH.
Very useful contentππ
Or you can use my automation in python for doing all this listed :)
github.com/dimon222/py-gitsshgen
Very useful... thanks for sharing!!