Sunday, April 10, 2022

[SOLVED] How to stop retyping "ssh [email protected]" over and over

Issue

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?


Solution

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)



Answered By - LinFelix
Answer Checked By - David Marino (WPSolving Volunteer)