Using SSH host aliases to simplify project retargeting

This tutorial shows how to use the SSH Host Aliases feature to quickly change the target machine of several VisualGDB projects. This feature allows switching a set of Linux projects to a different remote machine without manually editing each of them and is available in Custom and Ultimate editions of VisualGDB.

  1. We will start with creating a normal Linux project using the Linux Project wizard:01-newprj
  2. The first project we create will be a normal application:02-prjtype
  3. The next wizard page normally allows selecting a specific remote machine. However this time instead of hardcoding a machine name and user name, select “Create a new global alias”:03-alias
  4. Define an arbitrary name for your alias and point it to your existing machine connection:04-newalias
  5. Proceed with the default file transfer settings:08-alias
  6. Now we will create another project in the same solution. Right-click on the solution in Solution Explorer and select “Add->New Project”:06-newprj
  7. This time, select “Static Library” as the project type:07-lib
  8. Now the host selection page will list the alias we have previously created. Select this alias, press “next” and proceed with the default source access settings:08-alias
  9. Ensure you add the newly created library to the dependencies of the application project via Build Dependencies -> Project Dependencies:09-deps
  10. Replace the library source file to have a function returning the current host name:10-gethostname
  11. Modify the main source file to call that function and build your solution:11-build
  12. Set a breakpoint after the ‘cout’ line and start debugging. Verify that the correct host name is shown in the output window:12-print
  13. Now we will switch both projects to a different target machine by changing the target of our global alias. Select Tools->SSH Host Manager, go to the Host Aliases page and change the target for the alias you created before:13-hostmgrIf you have not made a connection to that machine before, you can add it on the first page of the SSH Connection Manager.
  14. Hit F5 to build and debug both the application and the library again. You will see that they both are now built and launched on a different machine:14-newhost

The host aliases affect all VisualGDB projects for a given user and are stored in the following file: