0

I'm new to Ubuntu. I want to access a remote server using terminal by using the shortcut key. For example, to access server Y, I will give ssh Y all the time. Just want to write a script to access the server so that I can call it every time and easy to remember. Which file do I need to add the command in?. How to run it after logging into my system?

Wolverine
  • 654
  • 4
  • 15
  • You can set up bash alias, eg. like [in this asnwer](http://askubuntu.com/questions/17536/how-do-i-create-a-permanent-bash-alias) – Tomasz Dec 30 '14 at 09:45

1 Answers1

2

Use ~/.ssh/config:

Add a host:

Host y
  HostName domain.com
  Port 666
  User username
  IdentityFile ~/.ssh/id_rsa-domain

And then access your host from a terminal:

ssh y

Also, you can create a shortcut to your terminal that opens a ssh session right away. Save this to a y.desktop file and place it in your ~/Desktop folder:

[Desktop Entry]
Version=1.0
Name=domain.com
Exec=gnome-terminal -e "bash -c 'ssh y'"
Icon=utilities-terminal
Terminal=false
Type=Application
Categories=Application;

Sure, there are number of ways on how you can bind a shortcut to some actions. The simplest in Unity is to use it's own settings: System Settings -> Keyboard -> Shortcuts -> Custom Shortcuts. You can bind one to execute ssh y.

Andrejs Cainikovs
  • 5,629
  • 1
  • 31
  • 39
  • Any reason for `bash -c 'ssh y'` instead of a direct `ssh y`? – muru Dec 30 '14 at 12:48
  • No. I have copied this code from [here](http://askubuntu.com/questions/436891/create-a-desktop-file-that-opens-and-execute-a-command-in-a-terminal). I guess changing this to just `ssh y` will work as well. – Andrejs Cainikovs Dec 30 '14 at 13:17