Difference between revisions of "SSH"

 
m (not specific to WSO)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Difficulty: 3
+
[[Category:How-To]][[Category:Computers]]
 +
'''SSH''', which stands for "secure shell", is a way to log into a server and execute commands on a [[command line]]. Here at Williams, you might SSH into [[Unix]] (unix.williams.edu) or to [[WSO]] (wso.williams.edu).
  
SSH without a password : Public-key authentication (UNIX and Mac OS X)
+
==Logging in with SSH==
  
To execute this solution, the reader should:
+
===Windows===
  
      be comfortable with the command line
+
1. Find and download putty.exe on this page:
  
 +
    http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
  
Note: Logging in without a password will save you a few seconds out of every day. It comes however, with an added security risk: if someone compromises your
+
The program doesn't need to be installed; just open the file you downloaded whenever you want to run PuTTY.
machine, they can then log into WSO with your account. If you are willing to bear this responsibility, then read on.  
+
 
 +
2. Open putty.exe
 +
 
 +
3. Enter "wso.williams.edu" (or whatever) for the host, and "SSH" for the protocol.
 +
 
 +
4. Click "Open"
 +
 
 +
5. Enter your user name and password when prompted.
 +
 
 +
6. If this is your first time connecting from this computer, you might get a message like this:  
 +
 
 +
    The server's host key is not cached in the registry. You
 +
    have no guarantee that the server is the computer you
 +
    think it is.
 +
    The server's key fingerprint is:
 +
    ssh-rsa 1024 7b:e5:6f:a7:f4:f9:81:62:5c:e3:1f:bf:8b:57:6c:5a
 +
    If you trust this host, hit Yes to add the key to
 +
    PuTTY's cache and carry on connecting.
 +
    If you want to carry on connecting just once, without  
 +
    adding the key to the cache, hit No.
 +
    If you do not trust this host, hit Cancel to abandon the
 +
    connection.
 +
 
 +
If this is your first time, don't sweat it, just say Yes. If you get this message and this is not your first time SSH'ing from this machine, you might drop us a line. For more information about host keys, read this page:  
 +
 
 +
    http://the.earth.li/~sgtatham/putty/0.55/htmldoc/Chapter2.html
 +
 
 +
7. You're in! Happy computing.
 +
 
 +
===Mac/Linux===
 +
 
 +
Let's say your user name is ewilliam and you want to log in to wso.williams.edu. From a [[command line]], type
 +
 
 +
ssh ewilliam@wso.williams.edu
 +
 
 +
Enter your password when prompted. If it's your first time and you get a warning about host keys, just say "yes".
  
The basic idea is that WSO's server will check for a special key on your computer every time you log in, and if it checks out, you'll be allowed in without entering a password. If
+
==Logging in without a password==
you'd like a more in-depth explanation, read on:
 
  
http://the.earth.li/~sgtatham/putty/0.54/htmldoc/Chapter8.html#8
+
Note: Logging in without a password will save you a few seconds out of every day. It comes however, with an added security risk: if someone compromises your
 +
machine, they can then log into WSO with your account. If you are willing to bear this responsibility, then read on.
  
 
Anyway, enough chit-chat. Here's how to do it:  
 
Anyway, enough chit-chat. Here's how to do it:  
  
 +
===Mac/Linux===
 
Adapted from http://bumblebee.lcs.mit.edu/ssh2/.  
 
Adapted from http://bumblebee.lcs.mit.edu/ssh2/.  
  
  1.Open a terminal
+
1. Open a [[command line]]
  2.Generate a public key and a private key. We'll copy the public key over to the server later.  
+
 
 +
2. Generate a public key and a private key. We'll copy the public key over to the server later.
 +
 
 +
  ssh-keygen -t rsa -f ~/.ssh/id_rsa
 +
 
 +
3. When it says something like
  
    $ ssh-keygen -t rsa -f ~/.ssh/id_rsa
+
  Enter passphrase (empty for no passphrase):
  
  3.When it says something like Enter passphrase (empty for no passphrase):
+
Just press return.  
    Just press return.  
 
  4.Let's copy the public key to WSO. Type
 
  
    $ scp .ssh/id_rsa.pub user@wso:~/.ssh/.  
+
4.Let's copy the public key to WSO. Type
  
   5.Cruise over to the WSO server:  
+
   scp .ssh/id_rsa.pub user@wso:~/.ssh/.
  
    $ ssh user@wso.williams.edu
+
5. Cruise over to the WSO server:
  
   6.Hop into the SSH directory:
+
   ssh user@wso.williams.edu
  
    $ cd .ssh
+
6. Hop into the SSH directory:
  
  7.Append the key to your list of authorized keys:
+
    cd .ssh
  
    $ cat id_rsa.pub >> authorized_keys2
+
7. Append the key to your list of authorized keys:
  
  8.Change permissions:
+
    cat id_rsa.pub >> authorized_keys2
  
    $ chmod 640 authorized_keys2
+
8. Change permissions:
  
  9.Kill the key.
+
    chmod 640 authorized_keys2
  
    $ rm id_rsa.pub
+
9. Kill the key.  
  
 +
    rm id_rsa.pub
  
 
All done! Now you can SSH and SCP to WSO without a password.
 
All done! Now you can SSH and SCP to WSO without a password.
  
-Evan Miller
+
===Windows===
 +
This link will give you some background about public-key authentication, and how to do it with PuTTY:
 +
 
 +
http://the.earth.li/~sgtatham/putty/0.54/htmldoc/Chapter8.html#8
 +
 
 +
A few tips:
 +
 
 +
* Use RSA
 +
* Your authorized keys file is called .ssh/authorized_keys2
 +
 
 +
Best of luck!

Latest revision as of 02:49, May 5, 2006

SSH, which stands for "secure shell", is a way to log into a server and execute commands on a command line. Here at Williams, you might SSH into Unix (unix.williams.edu) or to WSO (wso.williams.edu).

Logging in with SSH

Windows

1. Find and download putty.exe on this page:

    http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html 

The program doesn't need to be installed; just open the file you downloaded whenever you want to run PuTTY.

2. Open putty.exe

3. Enter "wso.williams.edu" (or whatever) for the host, and "SSH" for the protocol.

4. Click "Open"

5. Enter your user name and password when prompted.

6. If this is your first time connecting from this computer, you might get a message like this:

    The server's host key is not cached in the registry. You 
    have no guarantee that the server is the computer you 
    think it is. 
    The server's key fingerprint is: 
    ssh-rsa 1024 7b:e5:6f:a7:f4:f9:81:62:5c:e3:1f:bf:8b:57:6c:5a 
    If you trust this host, hit Yes to add the key to 
    PuTTY's cache and carry on connecting. 
    If you want to carry on connecting just once, without 
    adding the key to the cache, hit No. 
    If you do not trust this host, hit Cancel to abandon the 
    connection. 

If this is your first time, don't sweat it, just say Yes. If you get this message and this is not your first time SSH'ing from this machine, you might drop us a line. For more information about host keys, read this page:

    http://the.earth.li/~sgtatham/putty/0.55/htmldoc/Chapter2.html 

7. You're in! Happy computing.

Mac/Linux

Let's say your user name is ewilliam and you want to log in to wso.williams.edu. From a command line, type

ssh ewilliam@wso.williams.edu

Enter your password when prompted. If it's your first time and you get a warning about host keys, just say "yes".

Logging in without a password

Note: Logging in without a password will save you a few seconds out of every day. It comes however, with an added security risk: if someone compromises your machine, they can then log into WSO with your account. If you are willing to bear this responsibility, then read on.

Anyway, enough chit-chat. Here's how to do it:

Mac/Linux

Adapted from http://bumblebee.lcs.mit.edu/ssh2/.

1. Open a command line

2. Generate a public key and a private key. We'll copy the public key over to the server later.

  ssh-keygen -t rsa -f ~/.ssh/id_rsa

3. When it says something like

  Enter passphrase (empty for no passphrase): 

Just press return.

4.Let's copy the public key to WSO. Type

  scp .ssh/id_rsa.pub user@wso:~/.ssh/. 

5. Cruise over to the WSO server:

  ssh user@wso.williams.edu 

6. Hop into the SSH directory:

   cd .ssh 

7. Append the key to your list of authorized keys:

   cat id_rsa.pub >> authorized_keys2 

8. Change permissions:

   chmod 640 authorized_keys2 

9. Kill the key.

   rm id_rsa.pub

All done! Now you can SSH and SCP to WSO without a password.

Windows

This link will give you some background about public-key authentication, and how to do it with PuTTY:

http://the.earth.li/~sgtatham/putty/0.54/htmldoc/Chapter8.html#8

A few tips:

  • Use RSA
  • Your authorized keys file is called .ssh/authorized_keys2

Best of luck!