[SOLVED] ssh-keygen always creates root user in comment
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.