Sign in
Log inSign up
SSH Bookmarks

SSH Bookmarks

Stephan de Vries's photo
Stephan de Vries
·Dec 1, 2016

For years I've been using aliases or custom commands to make it easy to log into remote servers with SSH. Instead of having to type ssh someuser@123.456.789.012 I could just write ssh-foo, allowing me to login way faster. An example of such a command would be:

#!/bin/bash
echo "Logging into some server with someuser@123.456.789.012"
echo "" # add newline
ssh someuser@123.456.789.012

But today I discovered a new way of doing this, which is much cleaner.

The SSH config file

It turns out you can add such 'aliases' using the SSH config file (located at ~/.ssh/config) like this:

Host foo
  User someuser
  HostName 123.456.789.012

Now, instead of writing the complete SSH commando, you can just write ssh foo and you'll be logged in (providing you are using public keys to login). Neat! This method also works for the scp commando. So instead of doing scp /path/to/file someuser@123.456.789.012:/path/to/dir you can just write scp /path/to/file foo:/path/to/dir.

Private keys

If you are using private keys to log into the remote server, that's possible too! The SSH config comes with an optional 'IdentityFile' setting. This is where you can provide a path to a private key, allowing you to easily login. Just add this to the file:

Host foo
  User someuser
  HostName 123.456.789.012
  IdentityFile /path/to/private_key.pem

Conclusion

SSH bookmarks are super handy. Utilising the SSH config file, it's super easy to make new SSH bookmarks. I hope this helps to increase the speed of your workflow!

For a more in-depth article on how to setup SSH bookmarks using the SSH config file, checkout howtogeek.com/75007/stupid-geek-tricks-use….

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct