Change working directory from local to EC2 machine

want to access EC2 machine.

import os
os.system(‘ssh xxxxxxxxxxx.pem ubuntu@xx.xxx.xx.xx’)

Upto the 2nd line its going correctly. But I want to access the subfolder Documents in EC2 machine. That I cant using os.system(‘cd Documents’).
I want to access this:

ubuntu@xx.xxx.xx.xx:~/Documents $

Hi Codu, and welcome!

Thank you for your question, but you have posted this under the category
for the Python Software Foundation. Here we discuss legal and management
issues about the PSF, you won’t get any technical answers here unless
they are about law or trademarks.

You should post this question under the Users category.

Can you help us to help you please? The Users category comes first in
the list of categories on the website, what can we do to make it more
clear that questions about Python code from users of Python should go
there?

There is a library called paramiko.

But os.system() should work, too.

But then it is not a question concerning python.

First you need to get your command working on the command-line.

I think the tilde-syntax (~/…) does not work. By default the ssh connects to the $HOME of the user.

What are you trying to achieve? Do you want to get a file or put a file?

BTW, I would consider using ssh much as “dirty”. I would use https if it is possible.

Thanks a lot for your reply. I will definitely try this