ssh configuration: override the default username

HowTo: Change the default ssh configuration which by default  uses the current logged in user-name, which isnt working for my ansible setup.

Solution : We can achive this by using the SSH Config File where we can customize the settings to override ssh default settings.

Create a file called config inside ~/.ssh inside the file you can add:

e:g 1.


Host *
    User john

or add

e:g 2.

Host nixtechnix
    HostName nixtechnix.com
    User john

In the first example we are setting a common user john for all remote ssh connections.

And in second example we are setting a hostname specific user, also with second configuration we wont be required to give full hostname for ssh connection. we can simply connect with

ssh nixtechnix

 

 

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *