DEV Community

Cover image for Generate ssh-key, config and quick access server
Md Asaduzzaman
Md Asaduzzaman

Posted on

Generate ssh-key, config and quick access server

What we do?

  1. Generate the New SSH Key
  2. Copy the Public Key to the Server
  3. Configure the SSH Client
  4. Test the Connection

At a glance to see Diagram

To Do

1. Generate the New SSH Key (whithout passphrase)

ssh-keygen -t ed25519 -f ~/.ssh/id_rsa_deploy -N ""
Enter fullscreen mode Exit fullscreen mode

2. Copy the Public Key to the Server

ssh-copy-id -i ~/.ssh/id_rsa_deploy.pub server-user@server-ip
Enter fullscreen mode Exit fullscreen mode
  1. Configure the SSH Client
Host deploy-server
    HostName server-ip
    User server-user
    IdentityFile ~/.ssh/id_rsa_deploy
    IdentitiesOnly yes
Enter fullscreen mode Exit fullscreen mode
  1. Test the Connection
ssh deploy-server
Enter fullscreen mode Exit fullscreen mode

(Important): Fix permissions (if SSH refuses key)

Run these on your deployment machine:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/deploy_key
chmod 644 ~/.ssh/deploy_key.pub
chmod 600 ~/.ssh/config
Enter fullscreen mode Exit fullscreen mode

Top comments (0)