ssh short cut

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
 
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.
Code:
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
Code:
#!/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.
 
You could also create a config file in the ~/.ssh folder and add the following lines:
Code:
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.
 
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.
Code:
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
Code:
#!/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.
Thank You, I wrote the script and do ln -s {filename} and {target name} and I am happy thanks
 
Back
Top