简体   繁体   中英

SSH to a server and exit Python script (in the same shell)

I'm running a script that's determining login information for me, and in the end is outputting the login information that I need to use.

I am running the script in a terminal, and now I want it to SSH me with the credentials it has, exit the Python script on my computer and connect my current terminal to the new server.

Say I already have my sshHost, sshUser and sshPass as variables in the script. How do I run an SSH command in the current terminal and connect to that server?

I tried subprocess and spur, however I didn't really manage to get that going.

I would really appreciate your help and thanks in advance.

assuming the python prints the settings to stdout;

#!/bin/sh
export $(credentials.py)
exec ssh hostname

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM