Community discussions

MikroTik App
 
dombok
just joined
Topic Author
Posts: 1
Joined: Tue Aug 21, 2018 6:48 pm
Location: South Africa

Ampersand in Password

Mon Jan 28, 2019 6:56 am

Hi All,

I am using Python Paramiko for an SSH script to connect to Mikrotik OS.

I have the following:

pass1='pass1'
pass2='pass2&'

When connecting via SSH using the Paramiko client pass1 works perfectly and I can execute my commands.

When using pass 2 that has a "special character" is only times out.

This is looking like Mikrotik RouterOS is not accepting it correctly as I have escaped the special character in Paramiko with no luck.

Any ideas on this? Your help would be appreciated.

See my code below.

import paramiko
ip_address = 'X.X.X.X'
us3r = 'admin'
pass1 = 'pass1&'
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname=ip_address, port=22, username=us3r, password=pass1, look_for_keys=False, timeout=5)
 
Sarel0092
newbie
Posts: 48
Joined: Tue Aug 07, 2018 8:25 am

Re: Ampersand in Password

Tue Jan 29, 2019 2:42 pm

I use the below code, this works with special characters in the password:

import paramiko
ssh = paramiko.SSHClient()

ip1 = 'X.X.X.X'
u1 = 'user2'
p1 = '#$!@%&'

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip1, port=5252, username=u1, password=p1)
stdin, stdout, stderr = ssh.exec_command('ping 8.8.8.8 count=1')
output = stdout.readlines()
type(output)
print('\n'.join(output))

Who is online

Users browsing this forum: No registered users and 28 guests