Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSH Scripting.

Status
Not open for further replies.

felix001

Technical User
Nov 15, 2008
102
GB
My goal is to create a script that will copy a file from ServerA to ServerB using ssh.

But there is a problem in my plan. My plan was to use rsa ssh keys to authenticate ServerA when it connects to ServerB.

This would be fine but the problem I have is that I do not have the ssh-add binary on ServerA so that I can add the passphrase for an unattemded "login".

Also I would be unable to add the required binary due to the company policy.

Has anyone any other ideas how I an get this to work ??

A+, N+, CCNA, CCSA, SNPA
- Keeping You in the Know
 
i guess you need to find a more reasonable company, why they wouldn't let you put in a complete install of ssh is a bit weird but without it, you have two choices:

1. empty passphrase key.. seems silly though if you did that and couldn't just put in ssh-add

2. wrap ssh into an expect script, even more silly as you'll now have a passphrase in a cleartext script.

maybe there's some other clever way i'm not thinking of but really, there's a proper way to do this and thats to have the ssh-add function, if they wont let you run that then i'm assuming they don't want you creating unattended logins......
 
Personally I never use passphrases, nor the authentication agent... and I don't lose any sleep over it. Is there any reason why you feel you need to? If you just leave it blank unattended login will work fine.

Annihilannic.
 

I get along generating the keys with ssh-keygen and manually adding to the corresponding authirized_keys file.
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
isnt having no passphrase really insecure though....
also does anyone run into issues when using different version of ssh ie. sun, bsd, open etc etc

A+, N+, CCNA, CCSA, SNPA
- Keeping You in the Know
 
Not really unsecure (as opposed to insecure, which makes me think of something trembling in trepidation), as long as your keys aren't spread all over the place without being stored in properly secured directories, etc. As in all things security related, it's a trade off between security and functionality; for me passphrases defeat the object of replacing password authentication with keys if I still have to sit there and type something. Unless of course you choose to use an agent...

I have had very few issues with SSH on different platforms, the ones I have used are Solaris, Linux, HP-UX, AIX, SCO OpenServer and Windows (PuTTY, WinSCP and Cygwin).

Annihilannic.
 
try ssh-agent sh -c 'ssh-add' < /dev/null && bash'

this will start the ssh-agent, add your default idenity(prompting you for your passphrase), and spawn a bash shell. From this new shell you should be able to

ssh user@hostname
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top