From 8baff2c72d570c610cc9da270de0221829935136 Mon Sep 17 00:00:00 2001 From: guanghongwei Date: Mon, 22 Dec 2014 15:31:48 +0800 Subject: [PATCH] set PS1 --- connect.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/connect.py b/connect.py index 67424ade9..7a9328a79 100644 --- a/connect.py +++ b/connect.py @@ -106,6 +106,8 @@ def connect(username, password, host, port): Connect server. """ + ps1 = '[\u@%s \W]\$' % host + # Make a ssh connection ssh = paramiko.SSHClient() ssh.load_system_host_keys() @@ -120,9 +122,15 @@ def connect(username, password, host, port): except: pass + # Modify PS1 + channel.send('PS1=%s' % ps1) + # Make ssh interactive tunnel posix_shell(channel, username, host) + # shutdown channel socket + channel.shutdown() + if __name__ == '__main__': connect('guanghongwei', 'Lov@j1ax1n', '172.16.1.122', 2001)