I have successfully created public private keys to make passwordless ssh connection. I need to make connection with remote server, go to a particular path, and append some input to sample.log file. Currently I am using os.system("ssh xxx@aaa.vvv.com") and then the steps to append the input to sample.log file. But my script stops only aftwr making connection with using os.system("ssh xxx@aaa.vvv.com").
Asked
Active
Viewed 303 times
-1
-
When you execute that command, it starts an interactive SSH session. So it's waiting for you to type commands and then logout. – Barmar Feb 01 '22 at 05:40
-
1Use the Paramiko library to automate SSH sessions. – Barmar Feb 01 '22 at 05:40
-
You may try this if you don't prefer to use a library `os.system("ssh xxx@aaa.vvv.com \"echo 'new line' >> /my/path/sample.log\"")` – JSN Feb 01 '22 at 05:51
1 Answers
0
Paramiko Module is best suited for it.
I use it personally to make connections and execute comand from one device to another.
You can find more detailed information of paramiko on https://www.paramiko.org

Amogh Saxena - REXTER
- 634
- 1
- 4
- 14
-
I can not install any python package. BTW i got the solution, we can use cat script.py | ssh xx.xxx.xxx.xxx python - In script we can use os.system("ssh xx.xxx.xxx.xxx") – Fahad Naseem Feb 02 '22 at 06:07