Skip to content

Configuring SSH targets

effective-range edited this page Jun 21, 2024 · 2 revisions

Source of configuration

Currently SSH targets are supported by the extension. The SSH targets are sourced from a standard SSH configuration file. In the extension configuration the user can specify the location of the SSH config file, which defaults to ~/.ssh/config

image

Setting up key based login

The most convenient way of accessing the remote devices is to set up key based authentication. If you have an existing key, that you want to use, then start from step 2.

1. Generate an ssh key

To generate an ssh key, use the ssh-keygen utility. The tool will prompt for the location of the keys to be saved. For this step by step, let's say you inputted ~/.ssh/id_rsa_device1. Two files will be generated: a private and a public key. The public key has the same basename but .pub extension.

2. Install the public key into the target device

In order to be able to use public key authentication the following has to be true:

  • Key based authentication is enabled on the target device (/etc/ssh/sshd_config) (NB: usually, already enabled)
  • The public key is installed in the SSH login user's authorized_keys file.(NB: see detailed article)
  • The most convenient way is to use the ssh-copy-id utility, e.g: ssh-copy-id -i ~/.ssh/id_rsa_device1 user@target

3. Add SSH configuration for the device

Normally the identity file and user would be required to specified all times when one wants to ssh into a host. This can be relaxed by adding an SSH config. Add an entry for you new device in your designated ssh config file (e.g. ~/.ssh/config):

Host myhost
   HostName 192.168.0.1 # By IP
   #HostName er-edge-231415.local # or by DNS
   User admin # specify username to be used
   IdentityFile ~/.ssh/id_rsa_device1  # specify location of private key

4. Verify config from a terminal

If all is set up correctly, passwordless login should work from a terminal as well, by executing ssh myhost.

5. Refresh SSH targets in ER Dev Explorer

In order to reload the specified ssh config, the reload button must be used in the dev explorer

image

To verify operation, try to open a terminal from VSCode using the ERDev extension

image