Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: OT - SSH Help

by smullis (Pilgrim)
on Oct 29, 2004 at 10:12 UTC ( #403669=note: print w/ replies, xml ) Need Help??


in reply to Re: SSH Help
in thread SSH Help

For those of you yet to experience the pure joy of SSH used properly:

On a unix box: (or Cygwin).

%> ssh-keygen -b 1024 -t RSA <key in a good passphrase twice>

Now let's copy the Public key to the remote machine you want to have access to:

cat .ssh/id_rsa.pub | ssh -l<user> <target_ip> '[ -d .ssh ] || mkdir . +ssh ; chmod 700 .ssh ; cat - >> ~/.ssh/authorized_keys'

Now let's start up ssh-agent. You can either run you WM via ssh-agent: Add the following to your .xinitrc file:

exec /usr/bin/ssh-agent <Window Manager of choice>

or to your .bashrc:

SSHAGENT=$(which ssh-agent) SSHAGENTARGS="-s" if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then eval `$SSHAGENT $SSHAGENTARGS` trap "kill $SSH_AGENT_PID" 0 fi

Hooray... We're all set

Now, run ssh-add to add your private key passphrase to the ssh-agent keyring:
%>ssh-add <key in your passphrase>

Now, you can log into the remote machine with wanton abandon.


Repeat as necessary

I hope you'll all forgive the non-perlness of this post but I thought someone, somewhere may just find it usefull.

SM


Comment on Re^2: OT - SSH Help
Select or Download Code
Re^3: OT - SSH Help
by castaway (Parson) on Oct 29, 2004 at 10:46 UTC
    For bonus points, tell us how to do it on Windows, since that was the OS in question.

    C.

      Castaway - Ooooh... A challenge... ;-)

      There is a problem with ssh-add on Win32 in that the ssh-agent thingummyjob only applies to the ssh-agent associated with it. i.e. you cannot (without a serious hack) run Program Manager (or whatever new-fangled name it's called nowadays) under ssh-agent...

      But:
      In my cygwin ~/.bashrc I have the function:
      newshell() { rxvt -g 90x80+560+0 -sr -sl 5000 -vb -e /bin/bash --login - & }

      So, I run ssh-add and then whenever I need a new shell I run the newshell func. (I have an X Client running in the windowless mode...)
      I'm sure if you were clever (I think I've used up my allowance for that this year...) you could create the relevant scripts to create those funky little icon things that some people seem to like so much.


      SM

      If you just want to copy specific files and don't care about storing the password in the script you can use the scp client from putty. pscp is pretty easy to use and you should be able to pass everything you need to retrieve a file in one command. I've set similar things up in batch files.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://403669]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-11-27 06:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (180 votes), past polls