Connecting To Linux Using Putty

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Procedure to Set up the Keys to Access TSMAP Prod / Stage Servers via SSH

Providing for full password less, agent-based access requires a lot of steps, so we'll approach this in steps by first providing for regular passworded access to the system. This allows for testing of the initial installation and the ability to login before enabling the more advanced features.

Download and install the programs


Unlike most Windows programs, the PuTTY suite does not require an installer: the individual .EXE files are simply dropped into a directory where they are run directly. Putty can be downloaded from this link: http://www.putty.org/

The following files need to be downloaded are


PuTTY.exe Secure Shell client PuTTYgen.exe SSH public/private key generator Pagent.exe SSH key agent PSCP.exe Secure Copy from command line PSFTP.exe Secure Copy with FTP-like interface

Create a shortcut on the desktop for PuTTY.exe

It is helpful to have a shortcut on the desktop to make for easy access. To add this, right-click on the desktop and click New + Shortcut.

Launch PuTTY and configure for the target system


Double Click on the PuTTY.exe icon

Launch PuTTY via the shortcut, and it will display the configuration dialog box:

Create a Saved Session


Hostname/IP address: enter in server host name or IP address (e.g. tsmapapp-prd-01) Protocol: select SSH Under Saved Sessions: this name will usually be related to the machine you're connecting to (e.g. tsmapapp-prd-01) Select Save to save the settings Launch Saved Session With the saved settings from the previous step, we'd like to use them to connect to the target system. Launch PuTTY (if not already open), and in the Session section, click on the name of the saved session and click Load. Click Open to launch the connection.

When prompted, enter the username/password for your account on the remote system, and if correct, you'll receive a shell. Now you may begin working on the system.

Every time PuTTY connects with a server, it exchanges identification in the form of host keys. If the host key is unknown, or doesn't match what we've seen previously, it warns the user. For unknown hosts, this is mostly a pro forma operation, but for previously known systems it may suggest that the host is not the same one as originally connected.

Create and install a public/private keypair


Performing a one-time creation of a pair of very long binary numbers, which are mathematically related, does public key access. The initial configuration step is moderately involved, but need be done only once: once created, the key can be easily installed on as many remote systems as desired. Because the DSA keysize is fixed at 1024 bits, and the RSA keysize can be made much larger, we recommend a 2048 bit DSA key. Note that the default is 1024 bits, you have to manually override to select 2048. Double click the PuTTYgen icon to launch it OR click Start, then Run, then enter puttygen in the command-line box. Once launched it will display the main dialog box, shown below. Select the following key parameters: Select SSH-2-DSA Number of bits in generated key: 2048 Once the above was entered select Generate

You'll be prompted to create some randomness by moving the mouse around: this gives the system some additional entropy which helps create better keys. This takes just a few seconds to fully generate the keypair.

No!

Yes!

Once the Keypair has been generated, it will look similar to the below diagram.

Though the public key contains no sensitive information and will be installed on remote systems, the private key must be protected vigorously: anyone knowing the private key has full run of all remote systems.

Before saving you have the option to add the following:


Key Comment - The comment is optional but is customarily the email address of the key owner. It could also just be the owner's name. Key Passphrase - The private key is typically protected with a passphrase, and this phrase is entered twice in the fields indicated. It is recommended but not necessary to add a Passphrase to your key

Saving generated Key:


The key generated must now be saved, and this is done in three parts: select Save Public Key and Save Private Key both prompt for a filename, and the private key (with .ppk extension) should be saved in a safe place. The public key is in a standard format and can be used directly or indirectly by other software, and it looks like this: ---- BEGIN SSH2 PUBLIC KEY ---- Comment: "[email protected]" AAAAB3NzaC1yc2EAAAABJQAAAQEA0yX353EM64kovWjg5zqQxqXCw2uHIEmvqnHx fm2/DwU/xS/6rkRHNYCy+Nc8J5RXKPAXkuE1zK/4dS1XZEX6DiPiP+I/SRfPGlQ2 Ci7JAqSawOLSixnAGVO8A8Rfk09ZyQ/tneAqiHkpqmHs+7fAN+cHBM3MC2UUodQi 4LPdzdPVnoHp8Q8eTggTSj+mUEfHRdm0CE7RCW8WECPGl8OVZO70p8H8AXRqCbvf JutYE5yTe9fkzzivMMB7yvZNCRRafRbKsMRSlukPvBihJ0ApdtE/5sbIn36IpMAi 5QNCvWCmIDPKZmjNilY+krO4lTaYu2f9luBWS8f03zOE/rcwyQ== ---- END SSH2 PUBLIC KEY ----

The private key is in a PuTTY-specific format, which can't be used by any other software. It won't ever be looked at directly by the operator.

Install public key on Linux system


This is something that L2 Support engineer will do but you will have to provide them with your generated Public Key. With puttygen still open highlight the entire Public Key as shown below and copy and paste it into an email and send it to L2 Support Engineer so that they can add it to the ~csmp/.ssh/authorized_key file. Remember that the entire key (ssh-rsa-to-encrypted key (ie AAAB3...)-to-comment) must all be on one line.

Attach the private key to the SSH session


Now that the public/private keypair has been created, it can be associated with an SSH session. First, we'll do this in PuTTY by launching the program and loading the session of interest.

1. 2.

Under Saved Sessions select the server name which you wish to add the private Key to: e.g. TSMAPAPP-PROD-01 or TSMAPAPP-PROD-02 On the left columm: Navigate to Connection => Data, in the right panel populate the Auto Login username as csmp; Navigate to Connection => SSH => Auth in the Category pane on the left, then populate the Private key file for authentication field by browsing to the .ppk file saved previously.

3.

4.

Navigate to Session category level and select to Save located under the current saved session.

Repeated steps 1 to 4 for any additional saved server sessions you wish to add the Private Key to. At this point, PuTTY (on Windows) and OpenSSH (on Linux) are both configured for secure, public-key access.

Connect via the public key


Now that the configuration steps have been completed, we're ready to actually login using the public key mechanism, completely avoiding the password step. Launch PuTTY with options to load the saved session with the private key:

Rather than prompt for the account's password (which will differ on every remote system), it's instead asking for the passphrase, which is protecting the local private key. When the private key fits into the public key on the OpenSSH server, access granted and a shell presented to the user. It's important to note that though the user must type a secret word when logging in, the passphrase is associated with the local private key, not the remote account. Even if the user's public key is installed on 1,000 different remote servers, the same private-key passphrase is demanded for all of them. This greatly simplifies the task of remembering access credentials and encourages the choosing of strong, secure ones.

You might also like