Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

GNUPG and SFTP =(

  • 05-09-2007 09:17PM
    #1
    Registered Users, Registered Users 2 Posts: 8,581 ✭✭✭


    Hey guys,

    Maybe you can help with this problem...

    I've generated a public/private key pair and exported both. I'm trying to use SFTP to transfer files off my server to a remote server which is used to store backups. Since this will be fully automated, the "Password:" prompt when it hits the sftp <user>@&lt;host> part of the script is driving me nuts.

    You know where I'm meant to put the public key on the remote server? Or do I need to put a key from the remote server onto the local one ..or what am I doing wrong..

    Everything I've read centres on RSA encryption using SSH-Gen or something, but I'm using GNUPG which is using DSA encryption.

    Driving me nuts - each time I test and see Password: I die a little inside...


Comments

  • Closed Accounts Posts: 1,462 ✭✭✭bushy...


    From http://ludwikc.net , script to do it for you

    #!/bin/sh
    cd $HOME
    echo "Passwordless ssh (v. 0.6)"
    echo "Enter your ssh username:"
    read user
    echo "Host (or ip):"
    read host
    # Ports added in 0.4
    echo "Enter ssh port: (press Enter if you don't know)"
    read port
    if port=NULL
    then port=22
    fi
    echo "Wait for connection and type password for given username"
    scp -P $port $HOME/.ssh/id_rsa.pub $user@$host:~/id_rsa-passwordless.pub
    echo "Success: RSA key exported."
    echo "Last with-password ssh login..."
    ssh $user@$host -p $port "if [ -d $HOME/.ssh ]
    then
    echo "Success: Directory $HOME/.ssh/ exists."
    else
    echo -e "There is no $HOME/.ssh/ directory." && mkdir $HOME/.ssh && echo "Success: Directory $HOME/.ssh has been created"
    fi &&
    cat ~/id_rsa-passwordless.pub >> .ssh/authorized_keys && rm id_rsa-passwordless.pub && chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys && exit"
    echo "Authorization successful!"
    # Added in 0.3 version - symlinks providing easier login
    echo ""
    if [ -d $HOME/.ssh/passwordless_login ]
    then
    echo "Directory $HOME/.ssh/passwordless_login has been created during last passwordless_ssh usage."
    else
    mkdir $HOME/.ssh/passwordless_login
    fi
    echo ssh $user@$host -p $port >> ~/.ssh/passwordless_login/$host
    chmod +x ~/.ssh/passwordless_login/$host
    ln -s ~/.ssh/passwordless_login/$host $host
    echo "From now-on simply type ./$host, to log-in without password."
    echo "Passwordless ssh by Ludwik C. Siadlak (http://ludwikc.net). GPL Licence. Have a nice day!"


  • Registered Users, Registered Users 2 Posts: 8,581 ✭✭✭TouchingVirus


    Thanks for that bushy.

    I've just figured it out before reading your post but your's does what I wanted too :D

    My flawed logic believe PGP keys could be used to authenticate SSH sessions - maybe they can. I just generated a pair of SSH DSA Keys and added the public one to .ssh/authorized_keys and voila - works like a charm :D

    What can I say, small achievements like this make me feel less like a n00b each day :D


Advertisement