Solved

Ssh and sudo

Posted on 2012-04-11
6
833 Views
Last Modified: 2012-04-16
I have rsa keys setup between server A and server B.  server A needs to ssh into server B without a password.

Problem is that server B is setup to login as sudo without password.  So in order to get into server B, I have to log into a personal account, then do a "sudo su - accountname".  I am not given access to a password - it logs in automatically.

Realize this is probably the stupidest thing you ever heard but it is what it is.

I can't get ssh to log into server B without prompting for password even though I've correctly setup public, private keys (tested on a normal server with username and password authentication.)

Is this because of sudo for server B messes up things?  I read somewhere if you don't have password set for a server, ssh without password won't work.
0
Comment
Question by:lcor
  • 3
  • 2
6 Comments
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 250 total points
ID: 37833359
If ssh key mechism is setup, passwords are irrelevent.
Second if I understand you correctly , did you try:

ssh serverB "sudo su accountname -c ls"

Does this work for you?
0
 

Author Comment

by:lcor
ID: 37834081
farzanj, I'm experiencing technical difficulties at this time.  As soon as I can, I'll try the ssh with sudo.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37834088
No problem :)
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:lcor
ID: 37838312
farzanj, I tried your command and it still prompts for password.
I checked permissions on .ssh and authorized keys and they look good.
server A can successfully log into server C with the server A's public key in authorized_keys file
However server A is Solaris, server B is Linux, server C is Solaris
server A and server C run the same version of ssh
server A and server B run different versions of ssh
0
 

Author Comment

by:lcor
ID: 37838463
I also tried to setup keys between server A and server D.  They are both Linux and have sudo logins.  It doesn't work.  I seriously think it has something to do with sudo because the 2 Solaris servers have normal username and password logins but the Linux servers don't.
0
 
LVL 29

Accepted Solution

by:
serialband earned 250 total points
ID: 37852189
You should be able to log in to root with ssh keys even without a password.  I log in all the time with ssh keys to accounts without passwords.  The settings to deny root login should be in your sshd.config.  You just need to set PermitRootLogin to yes in sshd.config

PermitRootLogin yes

Open in new window


I do this on ubuntu and osx systems, which both require sudo for root and block root password login by default.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question