Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

All users have encrypted home folders on one server I maintain and one of the users (non-human account) has useful resources in its home directory shared via Apache.

In order to keep the user's home folder mounted, somebody will have to log in as that user. I achieve this by logging into that server using SSH and su that user. However, sometimes I forgot about that and logs out or closes the ssh client and other uses lose access to those files.

I am just wondering is there any command I can run to keep that user logged in?

I tried screen, but it does not work in su via ssh:

$ screen
Cannot open your terminal '/dev/pts/0' - please check.

I have also tried disown and nohup'ing cat <> /dev/zero but the process is still terminated after I log out.

share|improve this question
    
Your question is not very clear. What ssh client? Connected to where? Why exactly does the user need to be logged in? Can't you run whatever you need through cron? Could you show the actuall commands you need to run to make the files accessible? –  terdon Jun 21 '13 at 15:12
    
I have updated the question. There's no special command to access those files, but the encrypted home folder is only mounted when the user is logged in. I cannot use cron or any automated solution because the password cannot be stored on that machine. –  billc.cn Jun 21 '13 at 15:19
    
OK, so the user's home is mounted through autofs or similar? Is changing the way it is mounted an option? Why do you only mount the folder if the user is logged in? Anyway, nohup cat /dev/zero > /dev/null & allows me to exit my ssh session without stopping the process. –  terdon Jun 21 '13 at 15:26
    
It's just the standard Ubuntu encrypted file system (ecryptfs). Apart from this log in issue, it has proven to be very reliable and maintainable. I tried your nohup and it worked so my previous way must be wrong. However, CPU usage of that cat is 100%, so /dev/zero does not seems to be a very good input for this purpose. –  billc.cn Jun 21 '13 at 15:43

2 Answers 2

up vote 2 down vote accepted

screen works if you chown your current TTY to the target user, before suing to them.

But a better option would be to mount the home directory manually, using mount -t ecryptfs.

(You could also cheat by incrementing the refcount in /dev/shm/ecryptfs-<user>, so that it would never reach 0.)

share|improve this answer
    
I have tried incrementing /dev/shm/ecryptfs-<user> and it worked. Thanks! I will look into how to mount ecryptfs at some point I think. –  billc.cn Jun 24 '13 at 11:27

The reason your old nohup failed is because you did not send it to the background. If all you need is any random process that remains even after you log out, try something like this:

nohup sh -c 'while true; do sleep 60; done' &

I do agree with @grawity that if you are better off changing the way you mount the directory.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.