diff --git a/.bashrc b/.bashrc
index 65cd886f78608969cd43f9e0c21a368dfd2180b1..ce6dbffc1060eb2855e0b159e297211797721168 100644
--- a/.bashrc
+++ b/.bashrc
@@ -85,8 +85,8 @@ deduce_aws_region () {
 }
 
 ssh_keyscan_add () {
-    # shellcheck disable=SC2094
-    (ssh-keyscan "$@"; cat "$HOME/.ssh/known_hosts") | sort -u >> "$HOME/.ssh/known_hosts"
+    ssh-keyscan "$@" >> "$HOME/.ssh/known_hosts"
+    sort -uo "$HOME/.ssh/known_hosts" "$HOME/.ssh/known_hosts"
 }
 
 gen_csr () {