Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Servers & Networking
FedoraForum Search

Forgot Password? Join Us!

Servers & Networking Discuss any Fedora server problems and Networking issues such as dhcp, IP numbers, wlan, modems, etc.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 13th April 2012, 03:37 PM
sea's Avatar
sea Offline
"Shells" (of a sub world)
 
Join Date: May 2011
Location: Helvetic Federation (Swissh)
Age: 33
Posts: 2,608
linuxfedorafirefox
Problems using SSH with foreign server

Heyas

Foreign server in this case means, that its not 'inhouse' and that i have no physical access to it.
However, i had sent the Company my public key file, and they reportet that i should be able to login now.

i'm new to the whole SSH thing, so i have read some threads about it:
After successfully creating the default "id_rsa" file, i've done like suggested:
Code:
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
But when i try to connect, i get something like this (masked):
Code:
ssh -v simon@SERVER_URL
OpenSSH_5.8p2, OpenSSL 1.0.0h-fips 12 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to SERVER_URL [SERVER_IP] port 22.
debug1: Connection established.
debug1: identity file /home/simon/.ssh/id_rsa type 1
debug1: identity file /home/simon/.ssh/id_rsa-cert type -1
debug1: identity file /home/simon/.ssh/id_dsa type -1
debug1: identity file /home/simon/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.4p1 FreeBSD-20100308
debug1: match: OpenSSH_5.4p1 FreeBSD-20100308 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA xx:xx:xx:xx:xx.....
debug1: Host 'SERVER_URL' is known and matches the RSA host key.
debug1: Found key in /home/simon/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/simon/.ssh/id_rsa
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /home/simon/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
Password:
LDAP Password:
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: No more authentication methods to try.
Permission denied (publickey,keyboard-interactive).
And just where i 'would' need to enter the password i get stuck.
Regardless if i enter the password or not, it just repeats the question for it...

Any help, on what i'm missing, or where i should read more about is very welcome.

Thank you and have a nice weekend
Greets
sea

In the process of 'learning' ssh, this script was created, just replace sP by printf and sE by echo.
You may use this script and modify, as long you leave the comments untouched (or only add more comments):
Code:
    sshkeygen() { # [PASSWORD] [FILE]
    # Generates a ssh keyfile with the provided PASSWORD, if its empty, no password is set.
    # If you provide a FILE, you MUST provide the PASSWORD too, if no FILE is provided, a filename will be generated from your settings.
    # ssh-keygen handler written April 2012 by Simon A. Erat
        cstrength="768 1024 2048 4096 8192"
        cKind="dsa rsa"
        p=$HOME/.ssh
        sE "Select what kind of encryption you want:"
        select cKind in $cKind;do
            case $cKind in
                dsa)    cBit=1024   
                        break ;;
                rsa)    sE "Select encryption strength:"
                        select cBit in $cstrength;do break;done
                        break ;;
            esac
        done
        
        test "" = "$2" &&       sshFile="id-$cKind-$(whoami)_$cBit" && \
            sE "Using default file name: id-$cKind-$(whoami)_$cBit" && \
            sshFile="$HOME/.ssh/$sshFile" || \
            sshFile="$HOME/.ssh/$2"

        test "" = "$1" && ssh-keygen -t $cKind -b $cBit -f $sshFile ||\
            ssh-keygen -t $cKind -b $cBit -f $sshFile -N "$1"
        cat $sshFile.pub >> $p/authorized_keys
    }
__________________
Fedora Manual: http://docs.fedoraproject.org
Script-Tools: https://sourceforge.net/projects/script-tools/
sudo st tweak repo toggle fedora-rawhide ; st iso dl-fed -respin && st iso usb

Last edited by sea; 14th April 2012 at 01:20 AM. Reason: fixed typo, added string i had set external of that file.
Reply With Quote
  #2  
Old 13th April 2012, 05:57 PM
lpshark's Avatar
lpshark Offline
Registered User
 
Join Date: Jun 2007
Posts: 40
linuxchrome
Re: Problems using SSH with foreign server

is your public key on the "foreign" servers contained within the ~/.ssh/authorized_keys file?

permissions on ~/.ssh/authorized_keys file should be 600.

permissions on the ~/.ssh/ directory should be 700.
__________________
--
lpshark

fedora 18 / rhel 6.3 / centos 6.3
asus g73jw-a1 (intel® core™ i7-740qm - 2.93ghz, 8 gb ram, nvidia geforce gtx 460m - 1.5 gb vram, 2 x 500 gb seagate xt ncq solid state hybrid drives)
Reply With Quote
  #3  
Old 13th April 2012, 06:38 PM
pete_1967 Online
Clueless in a Cuckooland
 
Join Date: Mar 2006
Location: Here now, elsewhere tomorrow.
Posts: 3,929
linuxfirefox
Re: Problems using SSH with foreign server

To start with: Never add your private key to anything on your machine or server. authorized_keys are public keys that are allowed to connect on your server, it has nothing what so ever to do with connecting to a remote machine.

Most common error is that permissions for .ssh and files in it are too lax as lpshark points out, that leads to the rejection of your private key. Make sure that they are set to what he says first.

If you still can't connect to that server, then your public key hasn't been installed correctly on the remote server, or it's not correct one. The password and LDAP authentications are fallbacks offered by the server and if the company provided your either, then you need to use those.

What comes to your scrip, just couple notest:
"change the computers name" is nonsensical, the "coputer's name" is added as a default comment to make it easier to ID the keys, but you can add anything you want to.
DSA keys must always be 1024 bits.
You are not offering option to name the keys, thus they always overwrite existing keys, also you may not want to place them in .ssh directory at all if you are generating them for installation to another machine for example.

And last: You are dumping you private key to authorized_keys!!!
__________________
A Drink is Not Just For Christmas - SaskyCom :thumb:


“Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime” so now go and...
RTFM FIRST: http://docs.fedoraproject.org/ & http://rute.2038bug.com/index.html.gz

Last edited by pete_1967; 13th April 2012 at 06:47 PM.
Reply With Quote
  #4  
Old 14th April 2012, 01:09 AM
sea's Avatar
sea Offline
"Shells" (of a sub world)
 
Join Date: May 2011
Location: Helvetic Federation (Swissh)
Age: 33
Posts: 2,608
linuxfedorafirefox
Re: Problems using SSH with foreign server

Thanks, thats a typo (wrote it after true execution and forgot to add the .pub).

The DSA is set to 1024 bits in the select-case statement.
As written in the comments of the first 3 lines:
Quote:
sshkeygen() { # [PASSWORD] [FILE]
# Generates a ssh keyfile with the provided PASSWORD, if its empty, no password is set.
# If you provide a FILE, you MUST provide the PASSWORD too, if no FILE is provided, a filename will be generated from your settings.
Thanks for the file permission hint, looking into that now.

EDIT:
Not sure if the permissions were properly set before, i've just set them to
chmod 700 $HOME/.ssh
chmod 600 $HOME/.ssh/authorized_keys

However, me idiot used wrong login name
Either way, thank you guys, i have learned something more.

/solved
__________________
Fedora Manual: http://docs.fedoraproject.org
Script-Tools: https://sourceforge.net/projects/script-tools/
sudo st tweak repo toggle fedora-rawhide ; st iso dl-fed -respin && st iso usb

Last edited by sea; 14th April 2012 at 01:34 AM.
Reply With Quote
  #5  
Old 14th April 2012, 02:35 AM
stevea's Avatar
stevea Offline
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,302
linuxfirefox
Re: Problems using SSH with foreign server

Quote:
Originally Posted by pete_1967 View Post
To start with: Never add your private key to anything on your machine or server. authorized_keys are public keys that are allowed to connect on your server, it has nothing what so ever to do with connecting to a remote machine.

.....

And last: You are dumping you private key to authorized_keys!!!
No offense, but I know the issue but found that description very confusing in a "who's on first" sense.
"your machine", "server", "your server" and "remote machine" are ill defined.

An "ssh client system" with a (properly placed and permissioned) private key can allow a user to login to an "sshd server machine" with a (properly placed and permissioned) corresponding public key. For example the client machine can have the private key in the ~/.ssh/id_rsa, while the server machine has the corresponding public key in ~/.ssh/authorized_keys.

So assuming the user manages his private key correctly, then it's safe publish the public key. Installing the public key on other system's authorized_keys file just gives you the ability to authenticate on those other systems.

====

The above refers to user keys, there is also the matter of host keys for ssh.
__________________
None are more hopelessly enslaved than those who falsely believe they are free.
Johann Wolfgang von Goethe

Last edited by stevea; 14th April 2012 at 06:36 AM.
Reply With Quote
Reply

Tags
foreign, problems, server, ssh

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
File Name with Foreign Language peterever Using Fedora 6 9th November 2009 05:43 AM
Foreign language Happyyang Using Fedora 6 27th March 2007 03:12 AM
Foreign entry in /etc/hosts abeb Security and Privacy 8 23rd January 2007 09:48 PM
rpm foreign policy? SlowJet Fedora Focus 0 16th July 2006 07:28 PM


Current GMT-time: 08:29 (Friday, 24-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat