If you’re like me, you spend your whole day in SSH sessions. Simply knowing how to save a few seconds here and there will add up to minutes and hours over time.
Use Mosh for bad and laggy connections
https://mosh.org/ — use SSH while roaming, with bad or laggy connections, most importantly, support for local echo (ie, you don’t want for the server to send keystrokes back to you).
It’s available in lots of formats too, including distribution repos for Fedora, Debian, even Chrome!
Use SSH keys instead of passwords
Not only is it more secure, it’s just faster. How many times do you type your password a day?
Windows 10 has OpenSSH now — Goodbye PuTTY!
Windows Terminal SSH
Windows 10 has a built-in SSH client that you can use in Windows Terminal. In this tutorial, you'll learn how to set up…
One of the biggest benefits of this is that you don’t need to mess around converting SSH keys to a format that putty PuTTY can read. A native OpenSSH client on Windows means you can just use your keys as they are, and use the rest of the goodness of OpenSSH config.
PuTTY is just old, quirky, and hurts my eyes. Sorry.
SSH config — using a “host alias”
Most people don’t bother ever writing a SSH config. However, taking a few seconds to add a few simple statements can save you a LOT of time over a week or two.
I have a few servers which don’t have DNS records, or use ridiculous auto-generated usernames (cpanel, I’m looking at you). You can setup hosts with a simple alias and default settings, like usernames, and simply do“ssh cpanel”.
Also, I have some old BMC connections where I always login as ADMIN and need to enable support for old (bad) connection encryption;
Note; triple DES with cypher block chaining (3des-cbc) is hopelessly awful/insecure now-a-days, with much better options available. Just this hardware on these old machines just don’t support it.
You can set lots of defaults like this for hosts you access frequently.
Run a oneliner
You would be amazed at how many people don’t know that you can just run one line command and disconnect, simply like this;
user@host: ssh root@server poweroff
user@host: ssh root@server 'service httpd restart'
It just saves a few seconds here and there.
Terminal multiplexers should be a standard tool in your toolkit if you’re using command line and SSH a lot. Screen is great as it’s in almost every single distribution, but it’s largely been replaced by tmux now-a-days. They both work using very similar keybindings (Ctrl+A vs Ctrl+B).
One popular use is to split the terminal up into multiple “windows”, however one of most useful benefits is being able to “save and restore” sessions — especially if your network disconnects. (hint, use tmux and mosh in tandem!)
Edit a file over SSH with vim+”rsync”
This one is actually new to me — found it at the link below. This should be a easy time saver to edit files over SSH with vim, by opening files with the rsync protocol;
user@host: vim rsync://server:/etc/hosts
Once saved, the file is copied back to the server transparently. Nice one. :-)
Hopefully these SSH productivity tips will save you a few seconds here and there, which will add up to minutes and hours over time :-)
While doing a bit of extra research for this article and checking some things, I found a fantastic article here that includes many extra tips, including some advanced things that I didn’t know about!; http://blogs.perl.org/users/smylers/2011/08/ssh-productivity-tips.html