Script bafflements

View previous topic View next topic Go down

Script bafflements

Post by Huntress on Sun 27 Mar 2011, 5:02 pm

I hope this is the right forum for this question.

I'm writing a bash script to automatically load an authentication key and then log into a server via SSH. When manually entering commands into the command line (I'm using Cygwin, BTW), I can log into the server using either the key or the password, no problem. But when I run the script, neither authentication method works.

The script does run- I get the messages saying ssh-agent is running, the key has been loaded and the connection to the server is being made. At that point, I'm asked for a password instead of the key being used for authentication, but when I enter it, I get the message "Permission denied".

I don't think this is a problem with script permissions, because I can run it up to a point. I don't think it's a problem with the key permissions or the server, because I can log in if I do it all by hand. Help!!!

Here's what I have of the script so far. It's nothing fancy, just essentially the same commands I use on the command line.

Code:
#!/bin/bash
eval `ssh-agent`
ssh-add example

ssh -A -t -t -L localport:localhost:remoteport user@server

I did make sure that's the correct path to bash. Thanks in advance for your help.

Huntress

Unborn
Unborn

Posts : 3
Joined : 2011-03-27
Operating System : Vista

View user profile

Back to top Go down

Solution found

Post by Huntress on Fri 08 Apr 2011, 2:26 am

I solved this problem. I was starting Cygwin under a different user account than I'd given ownership of it to. This created a conflict when I used the shell script, which I think started a subshell that was under the control of the "owner" user account. The problem was solved by starting Cygwin under the appropriate account.

Huntress

Unborn
Unborn

Posts : 3
Joined : 2011-03-27
Operating System : Vista

View user profile

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum