# ssh short cut



## Ependi Silalahi (Sep 17, 2016)

So, I have my ssh(1) using id_rsa.pub to my home server from my laptop.
To connect to homeserver I open terminal and type `ssh username@myipaddress`
then I connect automatically.

How could I create small script on my desktop to connect to my homeserver.

This is probably easy for you but not for me.

Thanks


----------



## scottro (Sep 17, 2016)

I'm not sure what you mean by on your desktop, but you can certainly make some sort of alias, like homessh='ssh me@myhome'.  If you're using bash, you would put that in $HOME/.bashrc.

```
alias homessh='ssh me@myhome'
```

Then, (again assuming you were using bash) you could just type homes or something similar and tab completion should finish the command for you.

If you wanted a script, you could put something simple in $HOME/bin, calling it home.sh or similar.  It could just read

```
#!/bin/sh
ssh me@myhome
exit 0
```
Make it executable with `chmod 755 $HOME/bin/home.sh` and from now on, you could type home.sh in a terminal and it will run the command. That's the simplest way I can think of. If you want to make the script into something that you can click, it depends upon what desktop you're using.


----------



## hukadan (Sep 17, 2016)

You could also create a config file in the ~/.ssh folder and add the following lines:

```
Host homes
    Hostname  myipadress
    User username
    IdentityFile ~/.ssh/id_rsa
```
Then, you just have to type `ssh homes` to connect to your server. See ssh_config(5) for details.


----------



## Ependi Silalahi (Sep 17, 2016)

scottro said:


> I'm not sure what you mean by on your desktop, but you can certainly make some sort of alias, like homessh='ssh me@myhome'.  If you're using bash, you would put that in $HOME/.bashrc.
> 
> ```
> alias homessh='ssh me@myhome'
> ...


Thank You, I wrote the script and do ln -s {filename} and {target name} and  I am happy thanks


----------



## scottro (Sep 17, 2016)

Great, glad it worked, though actually, I think hukadan's solution is more elegant.


----------

