From c0f20267bbd7f0ae0f091e076692f138d855acb4 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 12 Nov 2025 15:00:19 -0600 Subject: [PATCH] Add Shorten SSH Commands With Aliases as a Unix TIL --- README.md | 3 +- unix/shorten-ssh-commands-with-aliases.md | 35 +++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 unix/shorten-ssh-commands-with-aliases.md diff --git a/README.md b/README.md index 7c71913..69fc5a6 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1686 TILs and counting..._ +_1687 TILs and counting..._ See some of the other learning resources I work on: @@ -1710,6 +1710,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Securely Remove Files](unix/securely-remove-files.md) - [See Where asdf Gets Current Tool Version](unix/see-where-asdf-gets-current-tool-version.md) - [Set The asdf Package Version For A Single Shell](unix/set-the-asdf-package-version-for-a-single-shell.md) +- [Shorten SSH Commands With Aliases](unix/shorten-ssh-commands-with-aliases.md) - [Show A File Preview When Searching With FZF](unix/show-a-file-preview-when-searching-with-fzf.md) - [Show Disk Usage For The Current Directory](unix/show-disk-usage-for-the-current-directory.md) - [Show The Size Of Everything In A Directory](unix/show-the-size-of-everything-in-a-directory.md) diff --git a/unix/shorten-ssh-commands-with-aliases.md b/unix/shorten-ssh-commands-with-aliases.md new file mode 100644 index 0000000..579355e --- /dev/null +++ b/unix/shorten-ssh-commands-with-aliases.md @@ -0,0 +1,35 @@ +# Shorten SSH Commands With Aliases + +Each time I need to SSH into one of my remote app boxes, like _staging_, I run a +command like the following: + +```bash +$ ssh root@staging-box.com +``` + +Instead of having to remember the user and domain, I can add aliases to my +`~/.ssh/config` file. + +``` +# Staging Server +Host staging + HostName staging-box.com + User root + +# Sandbox Server +Host sandbox + HostName sandbox-box.com + User root +``` + +Then I can SSH to each of these like so: + +```bash +$ ssh staging + +$ ssh sandbox +``` + +These aliases help a little bit, but they will help even more in situations +where I need other settings configured for the SSH sessions like `Port` or +`ForwardAgent`.