SSH has many features which are helpful when working regularly with files on remote servers, together they can give a vast increase in productivity over the bare use of ssh. If you regularly use ssh, it’s worth spending a little time learning about these and configuring your environment to make your life easier. I’m working with ssh over a year and here are few tips to make this work easier when connecting to remote server.
Too lazy to type password?
If currently you type a password when making an SSH connection, you can make connecting much more pleasant by setting up SSH keys. With keys you do get prompted for a pass phrase, but this happens only once per booting your computer, rather than on every connection. With OpenSSH generate yourself a private key with:
and follow the prompts. Do provide a pass phrase, so your private key is encrypted on disk. Then you need to copy the public part of your key to servers you wish to connect to. If your system has ssh-copy-id then it’s as simple as:
Otherwise you need to do it manually:
1. Find the public key. The output of ssh-keygen should say where this is, probably ~/.ssh/id_rsa.pub.
2. On each of your remote servers insert the contents of that file into ~/.ssh/authorized_keys.
3. Make sure that only your user can write to both the directory and file.
Then you can SSH to servers, copy files, and commit code all without being hassled for passwords.
Too lazy to type full hostnames?
If you’re tired of typing same username and server address follow these tips:
You can define hostname aliases in your SSH config, which is usually located in ~/.ssh/config though this can involve listing each hostname. For example:
1 2 3
You can even use wildcards to group similar hostnames, using %h in the fully qualified domain name:
1 2 3 4 5
Next time you type ssh dev it will connect to dev.example.com.
Don’t Type Usernames
If your username on a remote server is different from your local username, and when you often connect with the same user specify this in your SSH config as well:
1 2 3
Now even though my local username is nazarii, I can just do:
and SSH will connect to the nazik account on the server.