Solved

Ssh and sudo

Posted on 2012-04-11
6
840 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Fine Tune your automatic Updates for Ubuntu / Debian
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 how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

687 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