集群新建用户

以下案例在集群上创建一个名为”james”的用户, 注意最好一个用户建一个账号,账号最好是全英文
字母,如人名缩写:张三——“zhangs”,李四——“lis”。

以下以”#”开头的命令行表示是root用户执行的命令,”$”开头表示的是普通用户执行的命令。

1.新建用户

按照提示,需要输入两次密码,其余的回车即可。注意Linux下输入密码不会有任何显示
(Windows下输入密码可能显示为”****“)。

1
# useradd james -d [home目录,例如:/home-fs/james]

2.告知整个集群

注意这里是大写字母”C”:

# make -C /var/yp
make: Entering directory '/var/yp'
make[1]: Entering directory '/var/yp/abhpc-ai'
Updating shadow.byname...
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating netid.byname...
make[1]: Leaving directory '/var/yp/abhpc-ai'
make: Leaving directory '/var/yp'

3.添加用户到集群许可用户

把james加入到名为tensorflow的Account下(类似于小组的概念)。关于Account和User的关系,更详细的管理教程参考这里

# sacctmgr list assoc format=Clusters,Account,User,qos,partition,GrpTRES
Cluster    Account       User                  QOS  Partition       GrpTRES
---------- ---------- ---------- -------------------- ---------- -------------
abhpc-ai       root                          normal                          
abhpc-ai       root       root               normal                          
abhpc-ai tensorflow                          normal                          
abhpc-ai tensorflow      abhpc               normal                          
# sacctmgr add user james Account=tensorflow
Adding User(s)
james
Associations =
U = james     A = tensorflow C = abhpc-ai  
Non Default Settings
Would you like to commit changes? (You have 30 seconds to decide)
(N/y): y

4.用户初始化

按照提示,一路回车即可,不用输入其他任何东西。

# su james
$ cd
$ init-dsa.sh
Generating public/private rsa key pair.
Enter file in which to save the key (/home/james/.ssh/id_rsa):
Created directory '/home/james/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/james/.ssh/id_rsa.
Your public key has been saved in /home/james/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:SmnuUoInulf4ecwfNWn79wxdRoaL6wMb4Ki85Jfoddc james@abhpc-ai
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|               . |
|              . o|
|       ..  . . + |
|   o  +oS.= . . o|
|  + ++o..oo+ . o.|
| . *.O+.o o+E . .|
|. .oBo*. o.o. .o |
|.o .+=...   oo .o|
+----[SHA256]-----+

*注:这里的init-dsa.sh脚本添加到系统的PATH中,内容如下:

#!/bin/bash
cd ~/
ssh-keygen -t dsa
cd .ssh
cat id_dsa.pub >>authorized_keys
chmod 600 authorized_keys
echo "StrictHostKeyChecking    no">config
echo "UserKnownHostsFile    /dev/null">>config
chmod 600 config