How To
Summary
When EFS is enabled on a system, and a user's login password is synced up with their EFS keystore password, the user's EFS keys are automatically loaded upon login. The main AIX authentication routine passes the same password given during login to the EFS login routine, and the EFS login routine is able to authenticate using that password.
However, if SSH public keys are used to log in without password, there is no possibility to do the same because no password is given during the login attempt. In this case, to allow EFS keys to be loaded when public key authentication is in use, you must add the target user's authorized_keys to their EFS keystore.
Steps
The target system needs to have the following in its /etc/ssh/sshd_config file:
AllowPKCS12keystoreAutoOpen yes
FingerprintHash md5
AllowPKCS12keystoreAutoOpen yes
A more detailed example of how to get this working is given below.
# hostname
testlab179
# chfs -a efs=yes /efsfs
# lsfs -q /efsfs
Name Nodename Mount Pt VFS Size Options Auto Accounting
/dev/fslv08 -- /efsfs jfs2 2097152 rw yes no
(lv size: 2097152, fs size: 2097152, block size: 4096, sparse files: yes, inline log: no, inline log size: 0, EAformat: v2, Quota: no, DMAPI: no, VIX: yes, EFS: yes, ISNAPSHOT: no, MAXEXT: 0, MountGuard: no)
Set inheritance on this file system to automatically encrypt files:
# efsmgr -s -E /efsfs
Create a user and set its initial password:
# mkuser user2
# passwd user2
Changing password for "user2"
user2's New password:
Enter the new password again:
# ls -l /var/efs/users/user2
total 8
-rw------- 1 root system 0 Feb 23 20:22 .lock
-rw------- 1 root system 1914 Feb 23 20:22 keystore
# ssh user2@testlab179
user2@testlab179's password:
[compat]: 3004-610 You are required to change your password.
Please choose a new one.
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for "user2"
user2's Old password:
user2's New password:
Enter the new password again:
Connection to testlab179 closed.
# ssh user2@testlab179
user2@testlab179's password:
$ efskeymgr -V
List of keys loaded in the current process:
Key #0:
Kind ..................... User key
Id (uid / gid) ......... 595
Type ..................... Private key
Algorithm ................ RSA_1024
Validity ................. Key is valid
Fingerprint .............. 54e38285:4296092d:94e73214:cb5b69dc:39bb2686
Create a test file, which will be automatically encrypted due to the file system inheritance option that was set earlier:
$ echo "test EFS file" > /efsfs/user2_test
$ cat /efsfs/user2_test
test EFS file
# su - user3
$ ls -l /efsfs/user2_test
-rw-r--r-- 1 user2 staff 14 Feb 23 20:37 /efsfs/user2_test
$ cat /efsfs/user2_test
cat: 0652-050 Cannot open /efsfs/user2_test.
# hostname
testlab178
# mkuser user1
$ ssh-keygen -b 2048 -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user1/.ssh/id_rsa):
Created directory '/home/user1/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user1/.ssh/id_rsa.
Your public key has been saved in /home/user1/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:I3X0duVWzQgzoIzk7R7+YLkykNl66GZP8wdla16oaKI user1@testlab178
The key's randomart image is:
+---[RSA 2048]----+
| . o.+. o+|
| o + o . o.o+|
| o = . o . o|
| o .o. . . |
| +. So o |
| + .+.++ . |
| +o.*= . |
| *.*+.+o |
| E=.=.oo.. |
+----[SHA256]-----+
$ ls -ld /home/user2/.ssh
drwx------ 2 user2 staff 256 Feb 23 20:40 /home/user2/.ssh
$ ls -l /home/user2/.ssh/authorized_keys
-rw-r--r-- 1 user2 staff 395 Feb 23 20:40 /home/user2/.ssh/authorized_keys
$ cat /home/user2/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...etc...k5W5s3KUJ+j1rHiOMsjBoGR user1@testlab178
# hostname
testlab178
# su - user1
$ ssh user2@testlab179
<success>
$ id
uid=595(user2) gid=1(staff)
$ efskeymgr -V
There is no key loaded in the current process.
To continue, on the target system, push the keys from authorized_keys into user2's EFS keystore:
$ hostname
testlab179
$ id
uid=595(user2) gid=1(staff)
$ efskeymgr -P /home/user2/.ssh/authorized_keys
user2's EFS password:
Add these options to /etc/ssh/sshd_config on the target system and restart sshd:
AllowPKCS12keystoreAutoOpen yes
FingerprintHash md5
AllowPKCS12keystoreAutoOpen yes
$ ssh user2@testlab179
Last login: Wed Feb 23 20:52:45 CST 2022 on ssh from testlab178.aus.stglabs.ibm.com
$ efskeymgr -V
List of keys loaded in the current process:
Key #0:
Kind ..................... User key
Id (uid / gid) ......... 595
Type ..................... Private key
Algorithm ................ RSA_1024
Validity ................. Key is valid
Fingerprint .............. 54e38285:4296092d:94e73214:cb5b69dc:39bb2686
$ cat /efsfs/user2_test
test EFS file
Document Location
Worldwide
Was this topic helpful?
Document Information
Modified date:
04 September 2022
UID
ibm16559208