How to use rsa key for a different user?

Thread Tools Search this Thread
Operating Systems Linux Red Hat How to use rsa key for a different user?
# 1  
Old 11-28-2013
How to use rsa key for a different user?

Hi All,
I have a scenario where from machine1 I need to establish sftp/ssh to machine2.

Internet is full of examples of this how to generate they key-pair etc... but all examples assume that the account is the same on machine1 and machine2.

I would like to do the following:
1) user1 on machine1 invokes the following command:
ssh user2@machine2

I want this to be passwordless authentication. Also, user2 doesn't exist on machine1, it does only on machine2.

Here is what I did:
1) as user1 I created the keypair
ssh-keygen -t rsa

2) copied the public key over to machine2 under /home/user2/.ssh/
and created the authorized_keys file

Then as user1 I called the following command
ssh user2@machine2

Still prompting for password.

I tried on a test machine and if the user is the same on machine1 and machine2 then it's fine without password. But this is not what we need.

How can I make this working?

thank you!
# 2  
Old 11-28-2013
Originally Posted by snailrider
Internet is full of examples of this how to generate they key-pair etc... but all examples assume that the account is the same on machine1 and machine2.
I use keys across different accounts all the time... The key can't tell. It's failing for some other reason.

Check out permissions on ~/.ssh/ and its files, as well as the home directory. ssh doesn't like it if your home directory is world-readable or writable.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 11-28-2013
The steps you describe sound fine. It's possibly the permissions on the key file.

# On server B
[root@vmb ~]# useradd user2
[root@vmb ~]# passwd user2
Changing password for user user2.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

# On server A
[root@vma ~]# useradd user1
[root@vma ~]# su - user1
[user1@vma ~]$ ssh-keygen

[user1@vma ~]$ ssh-copy-id user2@vmb
The authenticity of host 'vmb (' can't be established.
RSA key fingerprint is dd:5a:88:65:38:67:42:3a:ef:63:2b:97:34:c1:ab:52.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'vmb,' (RSA) to the list of known hosts.
user2@vmb's password: 
[user1@vma ~]$ ssh user2@vmb
[user2@vmb ~]$

This User Gave Thanks to Scott For This Post:
# 4  
Old 11-28-2013
Thanks! indeed it was permission error.
on machine1 /home/user1/.ssh had too loose permissions.
This User Gave Thanks to snailrider For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Cybersecurity

Help troubleshooting RSA Key login attempts

I'm stumped on an issue I'm having with RSA key based SSH logons. I have 30 servers in a database cluster. They are all Red Hat Enterprise Linux Server release 6.4. I want to be able to run a command on all of them from any one of them using SSH. I generated private and public keys on... (1 Reply)
Discussion started by: derndingle
1 Replies

3. Shell Programming and Scripting

Bash script to create rsa key pair

Hello all, I am setting up a cluster of Mac Pro's which need to be able to talk to a master computer, traffic between the nodes and the master needs to take place without a ssh key. I need a script that will create a security key, save it to the default place, enter the password as no password.... (2 Replies)
Discussion started by: sdl27789
2 Replies

4. UNIX for Advanced & Expert Users

RSA host key addition

Guys How do i add RSA key for a host ? I was able to connect to a host some time back but now its not connectable ,via SSH. Message i get is : abhi@myHost:~/.ssh> ssh eatcid@yourHost @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION... (3 Replies)
Discussion started by: ak835
3 Replies

5. UNIX for Dummies Questions & Answers

How to change the RSA key fingerprint?

Hi there, I have a Linux Debian machine with the following fingerprint : e1:95:11:46:ff:d1:e3:4a:a3:34:1a:25:b4:d8:f1:cb. I'd like to set this fingerprint to : cd:19:bd:f6:8e:00:7a:69:14:52:a1:73:cb:15:a5:ca. I have very specific reasons to do that. So please only answer if you know how... (5 Replies)
Discussion started by: chebarbudo
5 Replies

6. Shell Programming and Scripting

automating RSA key pair generation

I want to automate the process of generating RSA keys. I want to remotley login to a linux machine from a windows maching without having to enter a password. For this I need to generate the RSA key pair. but I want to do this procedure on alot of linux machines. For which I was looking to automate... (2 Replies)
Discussion started by: lassimanji
2 Replies

7. Linux

RSA decrypt with public key ?

Dear All, I need to decrypt with private key most of the time and this works for RSA. At times I need to decrypt with public key (data is encrypted with private key). This does not seem to work via VB.Net. Is there support for such an activity in Java on Linux or Windows ? Please advise. ... (3 Replies)
Discussion started by: Sushma Y
3 Replies

8. Shell Programming and Scripting

SFTP in Shell Script with RSA-KEY or password.

I am trying to SFTP to a couple sites. One has an RSA-KEY that was sent to me. Currently I am running that manually using WinSCP. I would like to set it up as a CRON process on our Linux host (Sun). Can I use the rsa-key they sent me in any directory or does it need to be placed in a specific... (2 Replies)
Discussion started by: alemat
2 Replies

9. Shell Programming and Scripting

RSA key fingerprint needs to be avoided.

Hi All, I need to scp a folder from one host to another in a script. When I run a command , it asks me to authenticate for the RSA key fingerprint for the first time. # scp -r temp1 root@iqcarrot:/root/ The authenticity of host ' (' can't be... (2 Replies)
Discussion started by: nua7
2 Replies

10. UNIX for Dummies Questions & Answers

Register RSA Key fingerprint with JVM 1.4.2

Hi, We wish to register RSA key fingerprint with JVM 1.4.2 under UNIX environment. Any inputs how to go for it? The output we are getting as "The authenticity of host ' (' can't be established. RSA key fingerprint is... (0 Replies)
Discussion started by: asawari
0 Replies
Login or Register to Ask a Question