TST10 script is giving error: the handle is invalid - telnet

i am trying to connect to a remote machine(Windows) using TST10 script.i have the VPN access to that machine. i want to automate the telnet session using the TST10 script, kinldy help.
my code is:
xx.x.xxx.xx
WAIT "login:"
SEND "domain\username\m"
WAIT "password:"
SEND "VPNpassword\m"
WAIT ">"
SEND "command 1\m"
WAIT ">"
SEND "command 2\m"
Here the "username" is the VPN username and not the user account name on the remote machine and "domain" is different from my computer's domain.
If i am telnetting manually from my command prompt with the same VPN credentials, it is working.
But, using the script, i am getting an error : the handle is invalid.
Do i need to give the credentials of the user account in the script or these VPN credentials can also work.
Also, please tell me the reason why i am able to do it manually and why not using the script.

you need a double backslash between your domain and username:
xx.x.xxx.xx
WAIT "login:"
SEND "domain\\username\m"

Related

expect script doesn't work on ssh session

I login our company server by ssh, but the server ask my password and otp token.
Since i know my otp secret, so i can generate my otp in my script.
the prompt looks like this:
$ ssh mike#relay.office.com
Your password:
Your token:
let's assume my password is "123", and token is "456"
I wrote a expect script like this, which is supposed to work
#!/usr/bin/expect
spawn ssh mike#relay.office.com
expect "password:"
send "123\n"
send "456\n"
interact
However the prompt just like this:
$ ./expect.sh
Your [EMAIL] password:
Your [VPN] token:
^[[?65;1;9cInvalid credentials
You see, the ssh server return some massy code followed by "Invalid credentials"
I don't understand where the messy code came from.
In normal situation. Even i type the wrong password or token, it will just prompt "Invalid credentials" without any messy code. Is it some sort of anti-script login method from our ssh server?
Some Supplyment
Per answer below, i need to clarify, i forget to paste expect line in my script before. But even with it, the problem stands still.
And another thing i didn't mention before, but maybe related. when i type ssh mike#xxx.com. the server returned a QR code.(yeah, QR code in terminal.) it contains color escape as well as some unicode characters. I'm not sure if expect has any bug on handling unicode characters
The "messy code" is a terminal escape sequence, probably intended to change the colour or font of the following error message.
But the main problem here is that as written, your script will launch the ssh command and then immediately send the following lines, without waiting for ssh to connect to the remote machine. You should use expect commands to wait for each prompt before sending the response, e.g.
spawn ssh mike#relay.office.com
expect "password:"
send "123\n"
expect "token:"
send "456\n"
interact

SSH with Chilkat in VB6; but maybe generaly

I have written an application for SSH, but the originally used library is no longer developed and has old methods of encryption. Thus, it is not usable for contemporary devices. I am looking for alternatives and I found Chilkat.
I am able to start connecting to the device (Cisco switch for instance), but communication behaves in strange ways.
The basic principle of my program is based on talking client (my program) and server (Cisco switch). After the login is done, I get prompt saying that I would get into priviledged mode by command enable. I recongize this need by sign > at the end of prompt. I send command enable and awaiting prompt Password: After I get it I a send password. I am using two components and timer in this time :
success = ssh.ChannelSendString(channelNum, commandToSend & Chr(13), "ansi")
and
auxStr = ssh.GetReceivedText(channelNum, "ansi")
when I get word Password: in receiving text, I send password string like a commandToSend
but I get % Access denied
I am pretty sure that the password is OK; it seems like one extra enter is sent via connection, because during next returned text is this message :
Translating "passwordString"...domain server (255.255.255.255)
it indicates that passwordString was sent into the switch after message
% Access denied
not like an answer to Password: prompt.
I made debugging in the code to see what my program is sending to switch, but everything seems to be correct. Maybe some mistake in chilkat component ?
Has anybody similar experience ? Or explanation of this behaviour and advice how to solve it, please ?
Send the "enable" command (or just "ena") followed by a single CHR(13). Then get the output from the SSH server, which should be the "Password:" prompt. Then send the password followed by the CHR(13). Then get the output. The send each command terminated by a single CHR(13) and get the output after each command.

"Error getting tty, exiting' displayed on trying to ssh as admin

My code is
c = Net::SSH.start("192.168.x.x", "admin", :password=>"xyz")
puts c.exec "sh run"
c.close
Executing this I get "Error getting tty, exiting". What is the issue here, please help me.
Thanks,
Jade
This is happening because admin user on remote host doesn't have shell associated with it, so when you login ssh is getting that error while running the command.
Login to the remote machine and set a valid shell for the admin user or use a different user who has valid shell associated with it.
Also its good practice to specify the full path of the binary that you need to invoke, so instead of 'sh' its better to us '/bin/sh'.

SSH Expect Password Issue with Login

Hi I've the following script that make an ssh login to my server.
spawn ssh presnetwork#192.168.244.14
expect "*(yes/no)?"
send "yes"
expect "password:"
send "pwd\n"
close
it works fine but it doesn't pass 'pwd' value to system, so script goes timeout and quit.
Any suggestions?
You could try with "KbdInteractiveAuthentication" set to "no"
(ssh -o KbdInteractiveAuthentication="no" presnetwork#192....). SSH by default uses Keyboard Interactive Authentication, which is something expect might not understand.
I would strongly recommend that you use public key authentication instead (as already recommended by Flo). It is way easier to handle, and way more secure, and way more comfortable. If you are just looking for a way to login to a remote server without having to enter the password everytime, take a look at ssh-agent, which will store the password for you after you entered it once in your desktop session. If you really don't want to enter your password, use pam_ssh, where your desktop login password will be used.
By default, the expect command is not yet installed. So, you to install it to acquire correct output.

How do I authenticate to view mongodb's http console?

I'm running a mongodb process with the following line:
/usr/bin/mongod --dbpath /var/db/mongo --journal
According to mongodb's docs:
http://www.mongodb.org/display/DOCS/Http+Interface
I should be able to access the http console with http://myhost:28017
When I attempt to access the page it asks for authentication.
According to the docs if security is configured I would need to authenticate. But after looking at mongodb.org/display/DOCS/Security+and+Authentication it seems clear to me I'm not using any authentication. I don't run the process with the --auth option, nor are there any users when I run a db.system.users.find() command.
What's going on here?
I have been able to reproduce this, and this is not the intended behavior. I have filed https://jira.mongodb.org/browse/SERVER-4601 The fix version is 2.1.1
Thank you for bringing this to our attention!
In the meantime, there are two work-arounds:
1) Enter the credentials for authentication in the browser pop-up window
2) Remove all user credentials from each of your DBs (including admin) using db.system.users.remove()
Either of these should allow you to view the http console.
Greetings Brain,
i am using mongo V 2.4.6 and its on default port 27017, its http console is enabled by default but when you try to access from Network it ask for password and i dont know why as i am new to this and dont know the exact reason. by i have a way to access it.
Create a tunnel to your mongo Server and when you access, it wont ask for password. and if you are using putty.
enter host name
go to ssh on left menu options and click +
Than Click on tunnel
in Source port type 28017
in destination type localhost colon port 28017(sorry dont know how to write http url in localhost here in my post)
not click open and provide ssh username and password
now open browser on PC from where you are doing ssh .Type localhost and port 28017
and Boom its accessible and wont ask for username and password. hope it work for you, let me know if u need any help.