Create shortcut log-in command: Difference between revisions
(Created page with "It can be very tedious to have to type full command to log into a remote machine using the secure shell (ssh) when a remote machine is used often. A simple solution is to add a c...") |
No edit summary |
||
Line 1: | Line 1: | ||
It can be very tedious to have to type full command to log into a remote machine using the secure shell (ssh) when a remote machine is used often. A simple solution is to add a custom command to the .basrc. Open the .bashrc (which is in the root of home directory) using any plain text editor. E.g.: | It can be very tedious to have to type full command to log into a remote machine using the secure shell (ssh) when a remote machine is used often. | ||
== Add a custom command to the .bashrc == | |||
A simple solution is to add a custom command to the .basrc. Open the .bashrc (which is in the root of home directory) using any plain text editor. E.g.: | |||
<source lang='bash'> | <source lang='bash'> | ||
vi $HOME/.bashrc | vi $HOME/.bashrc | ||
</source> | </source> | ||
Then, using the <code>alias</code> function, define a new function derived from the <code>ssh</code> command and your personal credentials: | |||
<source lang='bash'> | <source lang='bash'> | ||
alias lx7="ssh username@scomp1095.wurnet.nl" | alias lx7="ssh username@scomp1095.wurnet.nl" | ||
Line 8: | Line 13: | ||
</source> | </source> | ||
The new function will be available from next login, therefore log out of the active terminal and log back in. From the freshly opened terminal, issuing the following command: | |||
<source lang='bash'> | <source lang='bash'> | ||
lx7 | lx7 | ||
</source> | </source> | ||
should give you direct access to <code>scomp1095</code>, for instance. If you do this in combination with a [[ssh_without_password | passwordless setup]], you will not even be prompted for a password. | |||
== See also == | |||
== External links == |
Revision as of 08:12, 25 November 2013
It can be very tedious to have to type full command to log into a remote machine using the secure shell (ssh) when a remote machine is used often.
Add a custom command to the .bashrc
A simple solution is to add a custom command to the .basrc. Open the .bashrc (which is in the root of home directory) using any plain text editor. E.g.: <source lang='bash'> vi $HOME/.bashrc </source>
Then, using the alias
function, define a new function derived from the ssh
command and your personal credentials:
<source lang='bash'>
alias lx7="ssh username@scomp1095.wurnet.nl"
alias hpc="ssh username@nfs01.hpcagrogenomics.wur.nl"
</source>
The new function will be available from next login, therefore log out of the active terminal and log back in. From the freshly opened terminal, issuing the following command:
<source lang='bash'>
lx7
</source>
should give you direct access to scomp1095
, for instance. If you do this in combination with a passwordless setup, you will not even be prompted for a password.