Wednesday, July 27, 2011

ssh and scp easier

Do you ever find yourself typing long commands when using ssh or scp? Something like
  ssh username@DNS-name.edu
or
  scp file username@111.222.33.444:~/file


By modifying your ~/.ssh/config file you can change the two previous commands to
  ssh comp1
and
  scp file comp2:~/file
where comp1 and comp2 are your names for the two computers and can be anything.

All you have to do is add a couple lines to you ~/.ssh/config file and you will save yourself a lot of typing.  The steps below outline the proceedure:
  1. Open ~/.ssh/config in your favorite text editor (you may have to create the file)
  2. For each computer you ssh or scp to add a section to the file that looks like

     Host computer_name
     Hostname 111.222.33.444 (or DNS Name)
     User username
     ForwardX11 yes


    computer_name is what you want to call the compter (comp1 and comp2 in the examples), 111.222.33.444 is the IP address for the remote computer (you can also use the DNS Name), username is the user on the remote computer.
That's it!  Now you can ssh and scp to computer_name with ease.

    No comments:

    Post a Comment