ssh connection unstable on remote server


 
Thread Tools Search this Thread
Operating Systems Linux Ubuntu ssh connection unstable on remote server
# 1  
Old 09-10-2012
ssh connection unstable on remote server

Hi

I hope someone can spot what is wrong with this ssh connection as it has me baffled.

I am trying to set up a remote ssh connection (passwordless) to a remote 'server', (Ubuntu laptop at home).

I have tried these steps with rsa and dsa key types, (currently dsa) -

1) ssh-keygen -t rsa -f bsa -P ''
2) cat bsa.pub | ssh brad@tx5xn 'cat >> .ssh/authorized_keys'
3) cat bsa.pub >> authorized_keys
4) Try to log into remote machine (tx5xn) -

Code:
/home/brad/.ssh >ssh brad@tx5xn
Agent admitted failure to sign using the key.
brad@tx5xn's password:

Same error for ssh into local host
Tried changing authorized_keys to authorized_keys2
Tried chmod 0640 for authorized_keys
Deleted all files above and the same with dsa key

I found that if I logged into the remote machine and executed these
commands then I could log in remotely from another session
without a password. But when I logged out from both sessions
and tried to log in again I was once again blocked and asked for a
password.

Code:
chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Listing one is the verbose output from the time I could log in without a password. (After executing the above on the remote server).

Listing two is when I am blocked. After logging out of both sessions and trying to log back in.

BTW, I have added the same key bsa.pub to my authorized keys file on my local client and can ssh into myself without a password reliably.

I don't understand why I can't get the passwordless connection to remain stable on the remote server.

Any ideas?

Listing One (Temporary success) =======================

Code:
 
/home/brad/.ssh >ssh -v brad@tx5xn
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to tx5xn [192.168.1.65] port 22.
debug1: Connection established.
debug1: identity file /home/brad/.ssh/id_rsa type -1
debug1: identity file /home/brad/.ssh/id_rsa-cert type -1
debug1: identity file /home/brad/.ssh/id_dsa type -1
debug1: identity file /home/brad/.ssh/id_dsa-cert type -1
debug1: identity file /home/brad/.ssh/id_ecdsa type -1
debug1: identity file /home/brad/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
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: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA 51:80:8b:c9:78:2a:13:bb:28:75:ad:83:b8:8d:91:1d
debug1: Host 'tx5xn' is known and matches the RSA host key.
debug1: Found key in /home/brad/.ssh/known_hosts:1
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,password
debug1: Next authentication method: publickey
debug1: Offering DSA public key: brad@ubuntu-dt64
debug1: Server accepts key: pkalg ssh-dss blen 433
debug1: Authentication succeeded (publickey).
Authenticated to tx5xn ([192.168.1.65]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_GB.UTF-8
Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-30-generic i686)
* Documentation: https://help.ubuntu.com/
3 packages can be updated.
0 updates are security updates.
Last login: Mon Sep 10 11:58:14 2012 from ubuntu-dt64.home
/home/brad>logout

Listing Two (Reverts to prompting for password) ===============

Code:
 
/home/brad/.ssh >ssh -v brad@tx5xn
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to tx5xn [192.168.1.65] port 22.
debug1: Connection established.
debug1: identity file /home/brad/.ssh/id_rsa type -1
debug1: identity file /home/brad/.ssh/id_rsa-cert type -1
debug1: identity file /home/brad/.ssh/id_dsa type -1
debug1: identity file /home/brad/.ssh/id_dsa-cert type -1
debug1: identity file /home/brad/.ssh/id_ecdsa type -1
debug1: identity file /home/brad/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
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: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA 51:80:8b:c9:78:2a:13:bb:28:75:ad:83:b8:8d:91:1d
debug1: Host 'tx5xn' is known and matches the RSA host key.
debug1: Found key in /home/brad/.ssh/known_hosts:1
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,password
debug1: Next authentication method: publickey
debug1: Offering DSA public key: brad@ubuntu-dt64
debug1: Authentications that can continue: publickey,password
debug1: Offering DSA public key: bsa
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: brad@ubuntu-dt64
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/brad/.ssh/id_rsa
debug1: Trying private key: /home/brad/.ssh/id_dsa
debug1: Trying private key: /home/brad/.ssh/id_ecdsa
debug1: Next authentication method: password
brad@tx5xn's password:

Files in .ssh directory on client -

Code:
 
-rw-rw-r--  1 brad brad  606 Sep 10 11:37 authorized_keys2
-rw-------  1 brad brad  668 Sep 10 11:33 bsa
-rw-r--r--  1 brad brad  606 Sep 10 11:33 bsa.pub

Files in Server side

Code:
 
-rw------- 1 brad brad 606 Sep 10 11:36 authorized_keys2

also tried

Code:
 
-rw-r--r-- 1 brad brad 606 Sep 10 11:36 authorized_keys2

# 2  
Old 09-10-2012
Did you set identity, the key the client sends?
# 3  
Old 09-10-2012
Hi DG

Once again I seem to have sorted it out but am unsure why it is fixed.

I created another account and went through the steps to enable it to log in without a password. Then I set used the key to enable the account I wanted to use and it seems to work.

I still don't understand why this works though...
# 4  
Old 09-10-2012
Permissions on the user's home directory have to be 755 or stronger?
# 5  
Old 10-08-2012
I know I'm late with this, but on an Ubuntu Client, you have the option of using
Code:
ssh-copy-id name@remote-server

which copies the key for the user on the client to the authorized keys file of the user you specify in the command on the server you specify in the command. Very simple and foolproof.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. BSD

Connection SSH to remote by ssh

Hello guys! I am setting up a script to access a unix remote server. My problem is that when I put the ssh line "my host", the script does not wait for the server response asking for the password to execute the line in which I put the password, that is, I need to put a form in which script has a... (1 Reply)
Discussion started by: aroucasp
1 Replies

2. Shell Programming and Scripting

Ssh to validate multiple remote hosts connection validation.

Dear Folks, I am trying to read a config file contains ip and port numbers. i want to read each line of the config file and check ssh connection is happening or not. Kindly guide. Config file: abc@1.2.342 22 abc@1.2.343 22 abc@1.2.344 22 abc@1.2.345 22... (9 Replies)
Discussion started by: sadique.manzar
9 Replies

3. Shell Programming and Scripting

How to automate SSH remote connection with a shell script

Hi Guys! I am trying to write a shell script for automated ssh. vairable user and passwd have initialized correctly, but when I use the following it still prompting me for the password. #!/usr/bin/bash user='root@10.14.76.225' passwd='admin' ssh $user $passwd uptime exit I... (3 Replies)
Discussion started by: pinpe
3 Replies

4. AIX

ssh failed to login in remote connection

i am in node acbs01b and i use the root@fcbs01b to login and i have the below message . ssh root@fcbs01b @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT... (6 Replies)
Discussion started by: thecobra151
6 Replies

5. Red Hat

Unable to SSH into machine - ssh_exchange_identification: Connection closed by remote host

For a few days now I have been experiencing issues when trying to SSH into 1 of my machine. I get the following output when running 'ssh -vvv': server1:/home/mymadq> ssh -l root -vvv server2 OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003 debug1: Reading configuration data /etc/ssh/ssh_config... (3 Replies)
Discussion started by: jaapar
3 Replies

6. Shell Programming and Scripting

ssh connection from remote machine in solaris

Hi! I have two solaris 10 machines(say 10.1.1.1,10.1.1.2). i have installed rsync on 10.1.1.2, 10.1.1.1::: Sun Microsystems Inc. SunOS 5.10 Generic January 2005 -bash-3.00$ ssh 10.1.1.2 "echo $PATH" Password:... (4 Replies)
Discussion started by: dddkiran
4 Replies

7. Shell Programming and Scripting

check ssh connection to remote host

I am using KSH and I need to check whether the remote host has been configured with ssh public key. Is there any way we can check inside a script? (6 Replies)
Discussion started by: praveenbvarrier
6 Replies

8. Shell Programming and Scripting

Remote SSH Connection Using Script

Hi, I am new to Shell Scripting. Can anybody help me in writing a Script Which Could Login from a Unix box to a Remote Unix box which accepts the user credentials automatically and display the result for checking the Disk Space Utilisation (Without running any SSH agent). (1 Reply)
Discussion started by: ajith_tg
1 Replies

9. Shell Programming and Scripting

Remote Connection (SSH)

Hello all, I connect usually to one enviornment "dev" daily and then ftp some files to some other enviorment "uat" and then login to "uat" and run some scripts to process these files. I was thinking to automate the process, where running one script from "dev" will complete all task required... (11 Replies)
Discussion started by: RishiPahuja
11 Replies

10. UNIX for Advanced & Expert Users

Solaris 9 remote login (ssh) drops connection

Hello All, I wonder if you can help me... Let me give you some set-up details before I ask you the question. I have Ultra-60 at home with Solaris 9 and recommended patch cluster installed. The machine is connected to a Linksys WAG54G ADSL router/modem through RJ45 ethernet cable. The... (2 Replies)
Discussion started by: ahmerin
2 Replies
Login or Register to Ask a Question