This is my finaly solution:
######################################################
#these imports are for ssh, date time and juniper info.
from junos import Junos_Context
import paramiko
from datetime import datetime
import jcs
user = Junos_Context['user-context']['login-name']
hostname = Junos_Context['hostname']
now = datetime.now()
day = now.strftime('%Y%m%d')
hour = now.strftime('%H%M%S')
#these are used to enter remote server ip, login and password
host = '10.0.0.1'
login = 'mylogin'
passw = 'mypassword'
#Sets up the ssh session and logs in as login "mylogin" with password "mypassword"
#to host '10.0.0.1'
#Also added "look_for_keys=False" and "allow_agent=False".
#Hopefully this is clear, if we can't establish a connection, we'll set "chan" to false.
#otherwise the configuration file is saved in the defined folder of the server
#with all the data of who saved the file and when.
#"All it's ok" message when done.
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username=login, password=passw, look_for_keys=False, allow_agent=False)
chan = ssh.invoke_shell()
except:
print "Login to %s failed" % (host,)
chan = False
if chan:
sftp = ssh.open_sftp()
sftp.put('/config/juniper.conf.gz','/backups/config/%s_%s_%s_%s_juniper.conf.gz' % (user,hostname,day,hour))
sftp.close()
ssh.close()
print "All it's OK %s ! " % (user,)
else:
print "Sorry, there is no connection to the host %s" % (host,)
#####################################end##############################
thanks all!