how to ssh to remote unix machines using private/public key


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to ssh to remote unix machines using private/public key
# 1  
Old 10-18-2010
how to ssh to remote unix machines using private/public key

hello,

iam able to ssh to a linux server from a linux server called "machine1" using the private/public key method, so I dont need to enter any password when I run my script but iam not able to ssh from machine1 to a UNIX server, access is denied.
note that I am using an application id which is a local id and if i run the command with my personal id (network id), it works fine.
Please let me know how to fix this problem.
Thanks
# 2  
Old 10-18-2010
how about:

login as yourself then
Code:
su - appid

after you get logged in. It will then ask you for appid's password.
# 3  
Old 10-18-2010
The ssh debug logs are usually good at telling you where it went wrong.

First, check out the ssh up there on the target host. Ensure you can 'ssh localhost pwd' passwordless as your id or the target id. Then, see if you can ssh between id's on the target host as localhost or its real name.

Ensure you can ssh to yourself on the starting host. Can you ssh to your id on the target host? (Hopefully, not a firewall issue!)

Then, it is just getting keys and authorized user lists straight.
# 4  
Old 10-18-2010
did you generate the private/public key for the local app id as well (on machine1)? and did you check that the public one has been distributed on the remote machine in the ~.ssh/authorized_keys ?
# 5  
Old 10-18-2010
s1: linux machine
s2: linux machine
s3: Unix machine

iam running a script that runs a ps command to different machines from a cron job.

when I shh from s1 to s2 --> works fine with my own id and application id
when I shh from s1 to s3 --> works fine with my own id but not with the application id

please advise, Thanks.
# 6  
Old 10-18-2010
In case you haven't, check
Code:
man ssh-copy-id

# 7  
Old 10-19-2010
make sure appli id exist on s1 and s3 (same uid would be better)
as appli_id@s1
Code:
ssh-keygen -t dsa

... or any other generation you like

then concatenate the content of public key
to the authorized_keys of the remote machine
Code:
appli_id@s3:~appli_id/.ssh/authorized_keys

make sur
Code:
ssh-agent

runs fine on both s1 and s3

on s1 load your key into the agent to auto identify
then
Code:
ssh-add

and try to connect

Make sure your ssh config if correctly setup (if necessary X11forwarding...)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Ssh public/private key user login problem

I have a user account configuration with ssh public/private key that works on multiple servers centos and rhel. One server (Server F) that is not working in centos 6.8. When i ssh into server f I get prompted for a password. I have verified the config and it all is good. I put sshd into debug... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

2. UNIX for Advanced & Expert Users

Private and public key encryption

Hi, we have private and public key, encrypt file using public and want to decrypt using private key. can you please advise below commands are correct or other remedy if unix have? encrypt -a arcfour -k publickey.asc -i TESTFILE.csv -o TESTFILE00.csv decrypt -a arcfour -k privatekey.asc... (2 Replies)
Discussion started by: rizwan.shaukat
2 Replies

3. Shell Programming and Scripting

Rsa public private key matching

Hi All, I have a requirement where i need to check if an rsa public key corresponds to a private key and hence return success or failure. Currently i am using the command diff <( ssh-keygen -y -e -f "$PRIVKEY" ) <( ssh-keygen -y -e -f "$PUBLICKEY" ) and its solving my purpose. This is in... (1 Reply)
Discussion started by: mritusmoi
1 Replies

4. UNIX for Dummies Questions & Answers

Public and Private Key generation for scp

Hi, What tool is used to generate public and private keys for SCP? Do you have an example script that generates these keys, puts them in files and then another example script that references them from SCP? Thanks, (9 Replies)
Discussion started by: Astrocloud
9 Replies

5. Solaris

Public private key setup issue in Solaris 10

Hi i am using solaris 10.I am trying to setup a public/private key but it is not working.Appreciate your repsonse on it There are two servers DB1 server and DB2 server. 1)I have generated public/private key using below step on both servers. ssh-keygen -t rsa 2)From DB1 server moved the... (6 Replies)
Discussion started by: muraliinfy04
6 Replies

6. UNIX for Dummies Questions & Answers

how to create a public/private key using ssh-keygen

Hi, please guide me create a public/private key using ssh-keygen, lets say I have been access to server named pngpcdb1with a userid and password ...!!! and also please explain in detail the concept of these keys and ssh as I was planning to use them in ftp related scripts..! Thanks in... (1 Reply)
Discussion started by: rahul125
1 Replies

7. UNIX for Advanced & Expert Users

SSH connectivity between two machines with private key

Hi I have two machines Mac1 and Mac2 logging in with same user id and same private key. can anyone let me know how to connect these two machine using ssh . or SCP files to other machine :wall: (1 Reply)
Discussion started by: madankumar
1 Replies

8. AIX

ssh public key auth "Remote login for account is not allowed" ?

Hello, Using AIX 6.1 boxes. User user1 connects from box A to box B using ssh. When password authentication is used everything is fine. When I configure user1 to use public key authentication sftp client works fine(no password asked), but ssh client fails. This is sshd log: Accepted publickey... (3 Replies)
Discussion started by: vilius
3 Replies

9. UNIX for Dummies Questions & Answers

SSL Public key/Private question

Hi everyone, I have a quick/newb question: I know that a public key is used to encrypt data and a private key is used to decrypt data but who keeps the public/private keys?? Does the Web Server hold both? Does the Web Server have the public key and does the client have the private key? ... (3 Replies)
Discussion started by: tical00
3 Replies

10. Windows & DOS: Issues & Discussions

Public/Private Key SSH from UNIX to Windows (Cygwin)

Hello all, I have a bit of trouble working a passwordless SSH from UNIX to Cygwin running windows 2k3. Here are some details. I AM able to SSH from the Windows box to the UNIX box using the keys. Also, I'm able to SSH from UNIX to Windows w/o the keys. However, when I try to do it with the keys... (9 Replies)
Discussion started by: kclerks11
9 Replies
Login or Register to Ask a Question