{"id":143,"date":"2015-05-01T15:22:04","date_gmt":"2015-05-01T15:22:04","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=143"},"modified":"2015-05-01T15:22:04","modified_gmt":"2015-05-01T15:22:04","slug":"linux-aliases","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/linux\/aliases\/","title":{"rendered":"Using SSH host aliases to simplify project retargeting"},"content":{"rendered":"\n<p>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.<\/p>\n<ol>\n<li>We will start with creating a normal Linux project using the Linux Project wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/01-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/01-newprj.png\" alt=\"01-newprj\" width=\"700\" height=\"456\" \/><\/a><\/li>\n<li>The first project we create will be a normal application:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/02-prjtype.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/02-prjtype.png\" alt=\"02-prjtype\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>The next wizard page normally allows selecting a specific remote machine. However this time instead of hardcoding a machine name and user name, select &#8220;Create a new global alias&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/03-alias.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/03-alias.png\" alt=\"03-alias\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>Define an arbitrary name for your alias and point it to your existing machine connection:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/04-newalias.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/04-newalias.png\" alt=\"04-newalias\" width=\"690\" height=\"174\" \/><\/a><\/li>\n<li>Proceed with the default file transfer settings:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/08-alias.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/08-alias.png\" alt=\"08-alias\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>Now we will create another project in the same solution. Right-click on the solution in Solution Explorer and select &#8220;Add-&gt;New Project&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/06-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/06-newprj.png\" alt=\"06-newprj\" width=\"699\" height=\"642\" \/><\/a><\/li>\n<li>This time, select &#8220;Static Library&#8221; as the project type:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/07-lib.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/07-lib.png\" alt=\"07-lib\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>Now the host selection page will list the alias we have previously created. Select this alias, press &#8220;next&#8221; and proceed with the default source access settings:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/08-alias.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/08-alias.png\" alt=\"08-alias\" width=\"696\" height=\"628\" \/><\/a><\/li>\n<li>Ensure you add the newly created library to the dependencies of the application project via Build Dependencies -&gt; Project Dependencies:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/09-deps.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/09-deps.png\" alt=\"09-deps\" width=\"459\" height=\"426\" \/><\/a><\/li>\n<li>Replace the library source file to have a function returning the current host name:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/10-gethostname.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/10-gethostname.png\" alt=\"10-gethostname\" width=\"697\" height=\"642\" \/><\/a><\/li>\n<li>Modify the main source file to call that function and build your solution:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/11-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/11-build.png\" alt=\"11-build\" width=\"699\" height=\"643\" \/><\/a><\/li>\n<li>Set a breakpoint after the &#8216;cout&#8217; line and start debugging. Verify that the correct host name is shown in the output window:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/12-print.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/12-print.png\" alt=\"12-print\" width=\"699\" height=\"644\" \/><\/a><\/li>\n<li>Now we will switch both projects to a different target machine by changing the target of our global alias. Select Tools-&gt;SSH Host Manager, go to the Host Aliases page and change the target for the alias you created before:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/13-hostmgr.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/13-hostmgr.png\" alt=\"13-hostmgr\" width=\"550\" height=\"545\" \/><\/a>If you have not made a connection to that machine before, you can add it on the first page of the SSH Connection Manager.<\/li>\n<li>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:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/14-newhost.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/linux\/aliases\/14-newhost.png\" alt=\"14-newhost\" width=\"699\" height=\"639\" \/><\/a><\/li>\n<\/ol>\n<p>The host aliases affect all VisualGDB projects for a given user and are stored in the following file:<\/p>\n<pre>%APPDATA%\\VisualGDB\\SSHConnections\\ConnectionAliases.xml<\/pre>\n<p><\/root><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use the SSH Host Aliases feature to quickly change the target machine of several VisualGDB<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[38,33,73],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/143"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=143"}],"version-history":[{"count":0,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/143\/revisions"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}