Skip to content

Instantly share code, notes, and snippets.

@nhthai2005
Last active May 22, 2022 01:28
Show Gist options
  • Save nhthai2005/ed1286dbcc5778d5eba1b560f1d404ec to your computer and use it in GitHub Desktop.
Save nhthai2005/ed1286dbcc5778d5eba1b560f1d404ec to your computer and use it in GitHub Desktop.
Common SSH Command Line

Common SSH Command Line

Generate a strong SSH key

  • RSA: ssh-keygen -o -t rsa -b 8192 -C marco.franssen@macbook-pro
  • Ed25519: ssh-keygen -t ed25519 -a 64 -C marco.franssen@macbook-pro

Ed25519: It’s the most recommended public-key algorithm available today! It has a 256-bit length and gives equal if not better protections as a 4096-bit RSA key. Reference: https://marcofranssen.nl/upgrade-your-ssh-security

Add passphrass into existing ssh key

  • Add passphrase: ssh-keygen -p -f ~/.ssh/id_rsa
  • Verify it: ssh-keygen -y -f ~/.ssh/id_rsa

Troubleshooting

  • ssh is failed with error port 22:2: Too many authentication failures
    Received disconnect from 192.168.56.140 port 22:2: Too many authentication failures
    Disconnected from 192.168.56.140 port 22
    
    ==> Fix it:
  • SSH authentication agent does not automatically start when using it from a remote server. This result in the following error message:
    $ git pull
    Permission denied (publickey).
    fatal: The remote end hung up unexpectedly
    $ ssh-add ~/my-ssh-key.pem
    Could not open a connection to your authentication agent.
    
    ==> To fix it requires manually starting ssh-agent:
    $ eval `ssh-agent -s`
    Agent pid 13442
    $ ssh-add ~/my-ssh-key.pem
    Identity added: /home/user/my-ssh-key.pem (/home/user/my-ssh-key.pem)
    $ git pull
    

    Reference: https://gist.github.com/mvneves/a6a69a53f039b3755900

  • After connected OpenVPN Server, then can ping, but cannot ssh ssh-bug ==> Fix it: Add MACs hmac-sha2-256 into /etc/ssh/ssh_config or ~/.ssh/config as a workaround
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment