vailixi Posted March 26, 2017 Share Posted March 26, 2017 (edited) I want to automate an SSH login. I was looking at sshpass or expect. But I haven't been able to find a working example of either. Anyboy use either of these? Also something of note. I don't know the hostname of the remote machine yet. I'm trying to get that in an automated way as well. I've tried raceroute, smbclient, nslookup, host, arp, and finger. Expect needs to expect user@host before it can send any commands over SSH but I don't know the hostname at this point. Edited March 26, 2017 by vailixi Quote Link to comment Share on other sites More sharing options...
digip Posted March 26, 2017 Share Posted March 26, 2017 (edited) Nmap can get the hostname ;) and you can output it in grepable format to use later Hostnames will only work if netbios or samba is enabled, or is in it's dns name as far as I know. MDNSrecon, is also be able to get the names for you while scanning for devices. You have to start avahi service first, then run "./mdnsrecon.rb x.x.x.x/x" to scan the subnet where x.x.x.x is the subnet and /x the subnet mask. I use it to scan my network to get machines and their names when I'm doing VulnHub CTF's. - https://github.com/darkoperator/MDNSRecon Mdnsrecon gives you some more info about the device as well, and is pretty fast at what it does. Expect requires a separate file for the expect commands and uses a different header than bash's #!/bin/bash. You can call it form a bash script, but can't use the expect commands directly in the bash script. Expect is not my strong suit. I've used it with a SMTP script before, but it's not something I'm fluent in. Might help you a bit - http://www.admin-magazine.com/Articles/Automating-with-Expect-Scripts Edited March 26, 2017 by digip Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.