LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-22-2012, 04:42 AM   #1
Luminaro
LQ Newbie
 
Registered: Oct 2012
Location: Vienna Austria
Distribution: DEBIAN, freescale BSP
Posts: 6

Rep: Reputation: Disabled
ssh-keygen always creates root user in comment


Hi,
I am new to Linux, currently using Debian plus MongoDB for cloud services and also going into ARM-based embedded applications.

My problem:
A shell script running under root uses ssh-keygen to create ssh keys.
Just before the keygen, su command is used to switch over to the tunnel-user.
I expected the comment within the public rsa key to be tunnel-user, but instead it is root@host.

As a workaround I tried to specify the comment explicitly with -c and -C but without success.

When giving the 'su tunnel-user command' interactively, I found that the prompt remains at root@host, but the command does not give an error, which I consider strange.

So in fact I have 2 questions:
- what can be the reason that the change of user (per su) is not shown in the prompt? (I experimented with .bashrc and .profile, but no success)
- where does ssh-keygen take its user information for he comment from? (could not find this in the documentation)

Note, why this is important: We have db clusters with a number of servers and tunnel users, so correctly commenting the keys from the beginning would be helpful and avoid admin errors later when the keys are copied into authorized_keys.

Thanks for all insights!
 
Old 10-22-2012, 07:08 AM   #2
mmheera
Member
 
Registered: Oct 2012
Location: Germany
Distribution: Ubuntu, Debian, Fedora,Windows 7
Posts: 107

Rep: Reputation: 11
You can check /var/log/messages file for any possible problem. Als you may try to run su with a space and -,like su - , which causes the environment variable to be changed also.

Have you tried using sudo? You may try:

sudo -u user command

Thanks!
 
1 members found this post helpful.
Old 10-24-2012, 11:46 AM   #3
Luminaro
LQ Newbie
 
Registered: Oct 2012
Location: Vienna Austria
Distribution: DEBIAN, freescale BSP
Posts: 6

Original Poster
Rep: Reputation: Disabled
partial solution

Thanks for the hints!

I found out why su did not work: Since the user was created per script as system user, it had :bin/false in its passwd entry, which disables shell response.
As workaround for debugging use the -s option to enable shell interaction: su - user -s /bin/sh
 
Old 10-24-2012, 12:25 PM   #4
Luminaro
LQ Newbie
 
Registered: Oct 2012
Location: Vienna Austria
Distribution: DEBIAN, freescale BSP
Posts: 6

Original Poster
Rep: Reputation: Disabled
Solved!

Since user switching now works properly with -s option above, ssh_keygen generates the correct comment!

Mystery solved, thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ssh-keygen for auto ssh login not working R00ts Linux - Software 26 09-23-2012 02:40 PM
SSH not working after ssh-keygen due to lack of entropy grob115 Linux - Security 8 08-28-2010 12:33 PM
ssh-agent, ssh-add and ssh-keygen AND CVS raylpc Linux - General 2 11-19-2008 03:50 AM
how can i create a ssh-keygen for user?? yenonn Linux - General 1 06-14-2005 11:37 PM
How to ssh-keygen? Baran Linux - Networking 5 04-26-2005 03:40 PM


All times are GMT -5. The time now is 11:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration