The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 23, 2019, 06:25:06 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Using SCP in a shell script, avoiding password  (Read 6674 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« on: November 01, 2007, 02:35:03 PM »

Hey all -

I have a need to scp a file nightly to a vendor. Accounts are good, doing it manually floats without complaint.

I've used the techniques described here: http://www.linuxjournal.com/node/8600/print to try to make it work in a script, but it still asks for the password when it runs (obviously it's not cron-able then). I have done the keygen, sent them the key, they are looking again to make sure that it is placed correctly. Is there anything special that I need to do on my side, or is there a special nudge-nudge-wink-wink-handkshake I might need to get this working correctly?

Any help greatly appreciated,
/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #1 on: November 01, 2007, 06:22:50 PM »

dig up that post i make on syndk8 ages ago about how to do that.
it was on a polish linux site (but was in english).
i think the title was controlling your boxes remotely.

even more cool is with ssh you can run apps on server, and pipe output back to client

example
ssh server ls
will give you listing
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: November 01, 2007, 11:14:50 PM »

I just searched my brains out, and am not in a place to walk backwards through all of your posts to find it... you wouldn't happen to remember anything about the polish linux site, would you?

BTW, I get where you're going with the ssh stuff as well... there's lots of coolness in there...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #3 on: November 02, 2007, 12:04:56 AM »

sorry
http://polishlinux.org/apps/ssh-tricks/

there used to be an OS section there, but it seems to be missing :O
« Last Edit: November 02, 2007, 12:06:36 AM by nop_90 » Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: November 02, 2007, 12:23:33 AM »

Great page, thanks a bunch. I'll probably scoff a bunch of it and post it here so that it doesn't go away...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #5 on: November 02, 2007, 04:33:32 PM »

I use it constantantly
I use scp to move the files up to my server
ssh to run shit on server and then pipe to me
basically with ssh you can do everything remotely that you do on ur desktop

and he explains how to set the key so u do not need password
also i think he has article how to make ssh into a proxy/tunnel
Logged
gnarlyhat
Journeyman
***
Offline Offline

Posts: 51



View Profile WWW
« Reply #6 on: November 02, 2007, 06:47:15 PM »

Nice info nop. I myself use a SSH tunneling server set up a home. I use it as a poor man's VPN whenever I'm outside using unsecured networks and wireless hotspots just to make sure that my data is not sniffed/hijacked. It's been sitting there collecting dust a lot lately as I don't see the need for me to be using unsecured public networks to access my sensitive sites/data.
Logged
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #7 on: November 03, 2007, 02:34:17 AM »

 Ditto
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
ratthing
Journeyman
***
Offline Offline

Posts: 75


View Profile
« Reply #8 on: November 08, 2007, 11:49:24 AM »

The first time you connect to the server via ssh, you have to do it interactively so you can accept the server's RSA fingerprint.

When using ssh to run commands, if the shell returns any kind of information to standard out, you'll have problems because of the nature of a non-interactive shell. 

Try ssh'ing over using the key without any commands to check what's being displayed on your terminal.

If you can't get in with the key due to it prompting with the password, you'll need to check the sshd_config file on the server side.  Sometimes key login is turned off.  And it's stating the obvious, but root logins are almost always turned off, with or without keys.

I get around this latter by executing "sudo" commands over ssh as a normal user.

There are also some weird escapes that have to be done when you send over ssh commands.  I can dig around for some old shell scripts  so I can remember the details if you need more info on that.

HTH--
=RT=
Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!