How to use SSH on Windows and Mac
- PuTTY Download Page
Freely available SSH client for Windows
Secure Shell - encrypted access for remote administration
SSH provides an encrypted alternative for the telnet and rsh suite of remote access functions. The first version was released in 1995, but ssh2 is preferred due to vulnerabilities discovered in ssh1.
If you use telnet on an insecure network, it's time to move on to SSH. Newsflash: there's no such thing as a secure network.
If you spend too much time looking up host names or IP addresses or usernames, then you will want to take advantage of this tutorial.
This tutorial will lead you through the following scenarios:
- create a saved session
- use keyboard shortcuts to access saved sessions
Each scenario will be presented first on Windows, then on Mac.
Note that there are enough similarities between the command line environment of Mac and Linux that the astute observer should be easily able to adapt the Mac tips to Linux.
My client operating system of choice is
Prepare your environment
If you're familiar with ssh and already have a client set up, skip this section.
If you're on a Windows computer, visit the Putty downloads and grab the latest installer. I installed using all the default options, which drops the executable into my C drive under the Program Files directory, creating a new directory named Putty.
Once the putty installation has completed, open your System control panel and select Advanced system settings. Scroll through the Environment variables until you find Path. Double-click the word Path and type in ;C:\Program Files\Putty at the end. (If you changed the default installation options, modify Path to match your changes.)
To launch Putty, click on the Start menu, look under All Programs, and scroll down until you find the PuTTY folder. Click on the PuTTY icon.
Alternatively, you can launch Putty using only the keyboard. When we changed the Path environment variable, we made putty.exe available from the Run command. Access the Run command with the key-combo Windows-r, type putty, then press the enter key.
Look on the sidebar for the screencaps.
Open the Applications folder, then open the Utilities folder. Click on the Terminal.app icon. You may want to pin this app to your Dock. Go to the Dock, right-click (or option-click) the Terminal.app icon, and select Options -> Keep in Dock.
If you find the mouse's point-and-click routine takes too long, try launching Terminal from Spotlight. The keyboard shortcut for Spotlight is command-space. You should see a drop-down window pop up from the upper right corner of your screen. Type in Terminal and press enter.
Terminal brings up Mac's built-in terminal emulator, which defaults to a bash command line. From the command line, type in ssh -V and you will see the version header from Mac's built in ssh client.
The screencaps on the side show the Spotlight window and the Dock options.
Create and save a session on Windows
Using the keyboard shortcut Windows-r to open the run command, type in putty then press enter. Under "Host Name" type in the IP address of the session you wish to open. Under "Saved Sessions" type in the shortcut name for the session. Select Connection -> Data from the Category tree on the left, and specify the remote username under "Auto-login username". Click back to "Session" on the Category tree, and click Save. Double-click the saved session name to open the remote connection.
Note that multiple sessions can be saved, with unique usernames and hostnames set up for each session. Once you create a new session (i.e., "myhost") you can use the keyboard shortcut to access that session directly with the @ symbol
For this section, I've posted a brief video tutorial instead of distinct screencaps.
Create and save session on Mac
To set up a saved ssh session on Mac, we will need to create and edit text files. My text editor of choice on the Mac is vi but you can use any program that saves ASCII output. Open the Terminal app, and create (or open if it exists) the file ~/.ssh/config. (The tilde is a shortcut for your home directory /Users/yourUserName)
Let's save the session settings for ssh://jdubya@myhost - but it turns out, there's no DNS entry for myhost, so we'll have to save the IP instead of the hostname. No worries, we can handle that! Add the following lines to .ssh/config
If there is a DNS name for the Host entry, then there's no need to specify a Hostname. Each distinct ssh profile will have its own Host, Hostname, and Username setting. Save your changes, and quit your text editor. Now access your saved session by typing the following command at the Terminal prompt:
To see how these variables are put to use, try the command again as ssh -v myhost for verbose output. More information on ssh config options is available in the online manual.
For the next SSH tutorial ...
I want to see a deeper dive on
More to explore
OK, just kidding, I can't take you deeper into the Mariana Trench but this short introduction only scratches the surface of what's available from ssh.
As the poll suggests, key authentication saves you the trouble of remembering passwords. Or for another thought, key auth can facilitate secure scripting by keeping passwords out of clear text script files.
Port forwarding opens up lots of possibilities.
Let me hear from you in the comment section, and I'll put together a hub on the topic of your choice. Good luck with ssh!