Home > Software engineering >  How to stop retyping "ssh [email protected]" over and over
How to stop retyping "ssh [email protected]" over and over

Time:04-08

My workflow always consists of opening a new terminal window, typing ssh [email protected] (or scp) followed by cd remote/directory/of/project

The domain is long and hard to type, as well as it being a big file path so this takes me ~20 seconds every time. What's the canonical, efficient way to do this that you would see a senior dev doing?

CodePudding user response:

You can create a script file with the commands you want to execute so you can just execute it instead of manually typing your ssh/scp/cd commands every time you have to do so.

CodePudding user response:

For not retyping ssh [email protected] that often, you can put it in you .ssh/config:

Host my_alias
HostName domain.com
User user

Afterwards, you can just type ssh my_alias.

For not retyping the path, you can

  • put the path in an alias in your .bashrc (alias cd_my_proj='cd remote/directory/of/project')
  • look it up in your bash history (usually with Ctrl R)
  • use a soft link (ln -s remote/directory/of/project ~)
  • keep the path open in a tmux (or screen) session

You may also google these pointers for more details (like how to save tmux session and further details in your .ssh/config)

  • Related