techbylooney.com

  • Home
  • Tutorials
    • cPanel & WHM Tutorials
    • Linux Software Tutorials
    • General Linux Tutorials
    • Wordpress & Elementor
tbl mobile logo
  • Home
  • Tutorials
  • General Linux Tutorials
  • How to create SSH shortcuts / aliases
18 May2016

How to create SSH shortcuts / aliases

Posted in General Linux Tutorials

Managing multiple servers can be very time consuming. Fortunuately, there are small tasks which makes this process much easier. In this quick tutorial, I will show you how to create SSH shortcuts / aliases in Linux.

Say for example that the servers which you are managing has the following hostnames:

  • server1.dcname.domain.com
  • server2.dcname.domain.com
  • server3.dcname2.domain3.com

You get the idea.. if you had to do something via a for loop, this would be very tedious i.e.

for test in server1.dcname.domain.com server2.dcname.domain.com server3.dcname2.domain3.com ; do ssh root@$test command here ; done

Let's create the shortcut file.

Step 1

Browse to your .ssh directory.

cd /root/.ssh/

Step 2

Create the config file.

vi config

Step 3

Add your shortcuts to the config file.

host server1
hostname server1.dcname.domain.com
host server2
hostname server2.dcname.domain.com
host server3
hostname server3.dcname2.domain3.com

Save and exit the config and you are ready to use your shortcuts i.e.

for test in server{1..3} ; do ssh root@$test command here ; done

Looks much better doesn't it? Enjoy your extra time!

 

blog comments powered by DISQUS back to top

Follow Me

You can find me on the following platforms!

youtubetbl

patreon new

Copyright © 2016 techbylooney.com. Content on this site may not be copied or redistributed.

  • Home
  • Tutorials
    • cPanel & WHM Tutorials
    • Linux Software Tutorials
    • General Linux Tutorials
    • Wordpress & Elementor