I have an Ubuntu 12.04 server which runs a python application. The application is started manually in tmux or automatically when the server starts.

Application processes http requests from android clients. It saves some data to hard drive:

with open(file_name, "w") as f:

Application sent exceptions to telegram chat:

OSError: [Errno 13] Permission denied: '/home/username/Desktop'

With an active ssh connection, everything works fine. After closing the client ssh terminal, I get a lot of "Permission denied" errors in the server's log about attempting to create a file or directory. After connecting with ssh (only connecting, without running any commands) everything works fine again and new files or folders are created by the application.

-- Does this happen when the program is started by the server and not in a tmux session? Yes. The problem appears in both cases.

-- Does connecting to the machine automatically reattach the tmux session? No. Attaching to tmux is manual(tmux a). Application works fine after ssh connection to server. Attaching tmux is not necessary.

How can the ssh connection affect a running application process or system access rights?

  • 2
    Please edit your question and give us some more information about what your python program does. Where is it trying to create the files/dirs? How is it creating them? What log does the error appear in? What exactly does the error say? Does this happen when the program is started by the server and not in a tmux session? Does connecting to the machine automatically reattach the tmux session? – terdon Feb 19 '16 at 10:28
  • 2
    You probably have encrypted home. – Jakuje Feb 19 '16 at 11:01
  • 1
    @Jakuje that sounds reasonable but would it result in a "permission denied" error? I would have expected a different error message (I've never used an encrypted home). – terdon Feb 19 '16 at 11:02
  • @terdon I am not sure. And not sure from Python. Unfortunately I have no Ubuntu around here. But worth trying. – Jakuje Feb 19 '16 at 11:05
  • 2
    There you go then. Yes, your home is decrypted when you connect to the server. If you want this to run when your user is not connected, you will have to do something else. I suggest you ask a separate question, explaining how your encryption setup works and what you are trying to achieve (do you need to write to the encrypted location or can you do so elsewhere, for example). @Jakuje you may as well post that as an answer so user1941407 can accept it and we can mark this as answered. – terdon Feb 19 '16 at 12:57

Default home-directories-encryption in Ubuntu works such as that the directory is decrypted when you open session (PAM) and encrypted back when the session closes. This is not ideal for server uses if you need to serve/store some data from that user.

You might store the data somewhere else (the easiest solution :) ) or disable encryption. If non of them is an option, please provide more details what you need to achieve.

There might be also way to preserve also the session (I didn't found out so), so you will not get the directory encrypted, but then there is probably no reason to have the encryption. :)

  • 1
    Problem solved. I change location of new created files. Thank you for help – user1941407 Feb 19 '16 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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