Need Help with Shell script???
Hello Guys,
I have been searching for a shell script which does login to remote server without DSA Key authentication. All I was following http://bash.cyberciti.biz/security/e...-login-script/ and just ran the script it threw errors. To troubleshoot I explored more with the forums and found that perl-expect has to be installed. I downloaded few packages ( as yum went unconfigured): Code:
perl-Expect-1.21-2.fc11.noarch.rpm [root@server ~]# sh script.sh script.sh: line 25: spawn: command not found script.sh: line 26: match_max: command not found script.sh: line 28: expect: command not found script.sh: line 30: send: command not found script.sh: line 32: send: command not found script.sh: line 33: expect: command not found [root@server ~]# Any idea if anything missing still to install / configure. |
running an expect script through sh instead of expect is not exactly a good start. It's not a shell script, why have you called it script.sh? not that it matters really. just make it executable and run it directly and in line with the shebang at the start, it'll run it with expect. It also clearly doesn't need perl-Expect at all. Just the real Expect.
|
[root@server ~]# whereis expect
expect: [root@server ~]# whereis spawn spawn: No expect command even after installing Perl-Expect package. Because of this, its not capable in running. pls suggest. |
as above, you don't want perl-expect, which is an internal perl library replicating expect. You want expect, which is expect. spawn is not a command, it's code in an expect script, which is what you're looking at. Install expect.
|
I need some help understanding the script:
Code:
#!/usr/bin/expect -f I installed expect RPM and it went successful. When I run : Code:
[root@server ~]# ./sshlogin.exp c0mp&t@# 192.168.254.129 who I am trying to ssh to my local machine for a trial. Isnt possible? |
With ssh you either login using an auth key or a passwd. Using 'expect' you can put the passwd in the expect script, thus making it unnecessary to manually enter the passwd from then on.
This is a REALLY bad idea from the security pt of view. Never put a passwd in a script if possible. A 3rd option is ssh-agent; basically you start the ssh-agent session, give it the passwd when reqd and any ssh cmds run from within that session can obtain the passwd on demand. |
Quote:
|
Why is it asking for the password? It's *NOT* asking for the password is it... where's the password prompt? There isn't one, that's a rmeote host key check, which is totally different. If it's getting stuck there, just manually ssh to localhost first, then run it again and it'll already know the key so won't ask again.
ssh scripts are somtimes unavoidable, but sshing as root should never be, don't ssh as root. that shouldn't even be possible on a properly managed system. |
All times are GMT -5. The time now is 05:58 PM. |