How to add id_dsa.pub to authorized_keys

The easiest way to add a copy of your key to a remote server is with the following command:

        
        
          
            
          
          
            
          
        

        cat ~/.ssh/id_rsa.pub | ssh user@remotehost 'cat >> ~/.ssh/authorized_keys'

      

Then you should be able to do this:

And log in without a password.

Creating a new SSH Key

If you don’t have any SSH key. You can create a new one doing this:

        
        
          
            
          
          
            
          
        

        ssh-keygen
      

For safety reasons, you can also have multiple keys according to the systems you are connecting your local machine to, like id_bitbucket_rsa or id_azure_rsa.

Update: 18 October 2023

If you are using MacOS Monterrey and you newly created SSH Key does not work make sure you add it to the keychain:

        
        
          
            
          
          
            
          
        

        ssh-add --apple-use-keychain ~/.ssh/your-id-rsa-file
      

Also, make sure your key is added on your SSH config file usually located here:

        
        
          
            
          
          
            
          
        

        ~/.ssh/config
      

The config file should look like this:

        
        
          
            
          
          
            
          
        

         Host *
   UseKeychain yes
   AddKeysToAgent yes
   IdentityFile ~/.ssh/your-id-rsa-file