- Run
ssh-keygen
You should see something like the following:
Initializing random number generator...
Generating p: ......................................++ (distance 530)
Generating q: ......++ (distance 208)
Computing the keys...
Testing the keys...
Key generation complete.
Enter file in which to save the key (/your_home_directory/.ssh/identity):
- This is asking you where you want to store your private key (your private key is something that should only be readable by you). Press enter and your private key will be stored in /your_home_directory/.ssh/identity. Otherwise, you can specify another filename at this point if you really want to. You will then see:
Enter passphrase:
- So, at this point you have a choice of how secure you want to be. You can either leave the passphrase blank (which is what I do) or you can stick in a passphrase. The difference is whether you want to be prompted for a passphrase when you use ssh or not (although as you'll see in a bit, there's a way to avoid typing in your passphrase for the duration of a session by using an agent). After you make your decision you will be prompted again:
Enter the same passphrase again:
- Now, your private key will be stored and your public key will be stored in /your_home_directory/.ssh/identity.pub (your public key is what everybody else will see).
Your identification has been saved in /your_home_directory/.ssh/identity.
Your public key is:
1024 37 99 ... 99username@machine.ucsd.edu
You public key has been stored in /your_home_directory/.ssh/identity.pub
- Next we will enable you to access any other machine with ssh without having to type in your password (your regular password, not the passphrase mentioned above). You will create a file called 'authorized_keys'. Here you will place your public key from above. If you have accounts at other sites like SDSC you can place your public key from there in here as well.
cp ~/.ssh/identity.pub ~/.ssh/authorized_keys
- If you configured ssh with a passphrase, you will need to do run
ssh-agent $SHELL
before running any MPI programs. Basically, this agent will automatically handle your authentication for the duration of your login session. Type ssh-add
to add your identification to this authorization agent.
- At this point, you should have secure shell all set up. However, you might just want to double check permissions on files in the .ssh directory. Basically, the only file that can be world readable is identity.pub. Everybody else should only be accessible by you.
- Note:The first time you ssh to a machine, you will get the following messages:
Host key not found from the list of known hosts.
Are you sure you want to continue connecting (yes/no)?
Just type in 'yes'. This basically says that you are going to trust that this machine is really whom it claims to be.