Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up an SSH config-file for beginners

First I am fairly new to SSH.

From this question I have seen the need and benefit of setting up an SSH config file. While I was doing my research I noticed that there is a lot to know on SSH and I also found out that I have been using SSH keys and not the SSH server. I have been using the keys to push my code to my hosted repos.

So now my questions are(I am using windows 10):

  1. Can I set up an SSH config file without a tool like openSSH, if so how do I do it?
  2. Where in my computer is this config file stored?
like image 408
YulePale Avatar asked May 24 '19 06:05

YulePale


People also ask

How do SSH config files work?

SSH client configuration files allow us to connect to servers with pre-configured commands. This saves typing each SSH command parameter when logging into a remote machine and executing commands on a remote device.

What is the default configuration file for SSH?

The SSH server has its own set of configuration files, including the SSH server system-wide configuration file named sshd_config. By default, these files reside in the /etc/ssh directory on the remote host.

Where is SSH config file in Windows?

In Windows, sshd reads configuration data from %programdata%\ssh\sshd_config by default, or a different configuration file may be specified by launching sshd.exe with the -f parameter. If the file is absent, sshd generates one with the default configuration when the service is started.


1 Answers

Generally, in Windows machine, the SSH config file stored in the following location: /c/Users/PC_USER_NAME/.ssh/

Just follow the steps in below (if you're using the Git Bash):

  1. Go to the .ssh directory /c/Users/PC_USER_NAME/.ssh/, click right mouse button and choose "Git Bash Here"
  2. Create a file named "config" with the following command:
touch config
  1. Now open the config file with the command:
nano config
  1. Now write the following lines inside the config file

Let's assume you've created two files named id_rsa_hub for Github and id_rsa_lab for GitLab

# GITHUB
Host github.com
   HostName github.com
   PreferredAuthentications publickey
   IdentityFile ~/.ssh/id_rsa_hub

# GITLAB
Host gitlab.com
   HostName gitlab.com
   PreferredAuthentications publickey
   IdentityFile ~/.ssh/id_rsa_lab
like image 161
Fatema Tuz Zuhora Avatar answered Nov 21 '22 23:11

Fatema Tuz Zuhora