Your Accounts

From DeepSense Docs
Revision as of 17:28, 1 December 2020 by Lyang (talk | contribs)
Jump to: navigation, search

Every DeepSense user has his/her own user account on DeepSense's platform. It is important a user understands his/her account. If a user understands and manages his/her account well, he/she can save a lot of time while working in a HPC environment.

How to manage your profile to make your environment work better

Every user has a profile in his/her home directory. The file's name is '.bashrc'. It is automatically generated for you when your DeepSense account is created. The profile controls the environment variables and other profiles during a user's login session. There is a global profile on the system and a lot of environment variables and profiles have been setup for users such that users do not need to specify them in their own profiles. For example, a user can directly run C and C++ compiler 'gcc' without specifying the path of it. However, users may install software in their own home directories or use some installed software on our system, but the paths are not set in the global profile. In such a case, a user may want to set up some paths in his/her profile to make his/her work on our systems more convenient. To view the contents of your profile, you can use command 'cat ~/.bashrc'. To list the file, you will have to add parameters '-a' to the command 'ls' to see the filenames with a '.' at the beginning. For example:

[username@ds-lg-01 ~]$ ls -a
. ..                                                             anaconda2                                                     anaconda3                                               .bash_history                                                 .bash_logout                                                  index.html .bash_profile                                                 iris_test.csv .bashrc                                                       iris_training.csv

If you would like to modify your profile, you can use command 'vi ~/.bashrc' or other editors to change the contents of the file. For example, if you installed anaconda3 in your home directory and you would like your login session to automatically source the environment of your installed anconda3, you can add the following line to the end of your profile:

Source ~/anaconda3/etc/profild.d/conda.sh

The above command assumes that anaconda3 is installed under your home directory. You may modify the path above when editing your profile. You can also add more paths to the environment variable PATH to run commands without specifying their absolute paths. For example, you installed a software called 'examplesoftware' and the binaries of the path is '~/examplesoftware/bin'. You can add the following line in your profile:

export PATH=$PATH:~/examplesoftware/bin

How to set up passwordless ssh

Users may be tired of typing password again and again while logging on the head nodes and compute nodes. The following instruction helps users set up passwordless ssh between their local machine and DeepSense's head nodes, and DeepSense's head nodes and compute nodes.
Basically, users need to generate a pair of private key and public key for a different system to allow passwordless ssh. The follow guide shows how to set up the passwordless ssh login from your local machine to the login 1 node of DeepSense.

Generate private and public keys

In the terminal of your local machine, generate the private and public keys using the following command:

  ssh-keygen -t rsa

You will see something similar to below:

    [username@your local machine ~]$ ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/username/.ssh/id_rsa): [Press enter key]
    Created directory '/home/username/.ssh'.
    Enter passphrase (empty for no passphrase): [Press enter key]
    Enter same passphrase again: [Press enter key]
    Your identification has been saved in /home/username/.ssh/id_rsa.
    Your public key has been saved in /home/username/.ssh/id_rsa.pub.
    The key fingerprint is:
    5f:ad:40:00:8a:d1:9b:99:b3:b0:f8:08:99:c3:ed:d3 username@your local machine
    The key's randomart image is:
    +--[ RSA 2048]----+
    |        ..oooE.++|
    |         o. o.o  |
    |          ..   . |
    |         o  . . o|
    |        S .  . + |
    |       . .    . o|
    |      . o o    ..|
    |       + +       |
    |        +.       |
   +-----------------+

There is a directory called “.ssh” on both your local machine and DeepSense’s login nodes 1 and 2 in your home directory. You can go to the “.ssh” directory on your local machine to see if there are two files named “id_rsa” which is your private key and “id_rsa.pub” which is your public key. The private key is the key you keep only on your local machine. While you use the public key to let remote system know you would like to ssh to it using the pub key without a password. The next step tells you how to do this.

Put the public key on login 1 of DeepSense

Get the contents of the public key on your local machine. You can use command “cat” to do this. For example:

         cat .ssh/id_rsa.pub
         ssh-rsa  AAAA/ OOfh/BL+ESZ1GQ8Ms8kBPUmV/w== username from abc.com

The actual key is not this short as shown above. It is just an example. You copy the whole contents of the public key. Now login the DS login node 1. You still have to use password at this moment. After you are on the system, open “.ssh/authorized_keys” and paste the public key you just copied to the last line of this file.

Set correct permission of authorized_keys

You already have the public key of you local machine on login node 1. But you will have to set the permission of the file “.ssh/authorized_keys”. Run the following command to set the permission:

chmod 640 .ssh/authorized_keys

Now, you should be able to ssh into login node 1 without a password.

You can do the same thing for login node 2. If you want to set passwordless ssh between the login node and other nodes in the cluster, you can generate the private and public keys on one login node. Then, put the generated pub key in the “.ssh/authorized_keys” file. Because your home directories are all shared across the cluster, you only need to do this on one node and all nodes can see your public key so you can ssh to them without a password.