View previous topic :: View next topic |
Author |
Message |
ppeetteerr n00b
Joined: 19 Nov 2007 Posts: 58
|
Posted: Fri May 30, 2008 6:13 pm Post subject: ssh as different user |
|
|
Ok so my username on my home computer is peter. My user name on host.com is ppeetteerr. In the past I've done
Code: | ssh ppeetteerr@host.com | or when I'm feeling adventurous Code: | ssh -l ppeetteerr host.com |
My question is: is there a way to change my default user name when I ssh. So I can just ssh host.com and it logs me in as ppeetteerr? |
|
Back to top |
|
|
Aleksi Halkola n00b
Joined: 02 Aug 2005 Posts: 21
|
Posted: Fri May 30, 2008 6:27 pm Post subject: |
|
|
you can do that in ~/.ssh/config. Just add teh following
Host host.com IP
HostName full.host.name.com
User ppeetteerr |
|
Back to top |
|
|
think4urs11 Bodhisattva
Joined: 25 Jun 2003 Posts: 6659 Location: above the cloud
|
Posted: Fri May 30, 2008 6:27 pm Post subject: Re: ssh as different user |
|
|
Code: | cat ~/.ssh/config
Host schnickschnack
HostName host.com
User ppeetteerr
me@box $ ssh schnickschnack |
_________________ Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself |
|
Back to top |
|
|
mimosinnet l33t
Joined: 10 Aug 2006 Posts: 717 Location: Barcelona, Spain
|
Posted: Mon Jun 09, 2008 6:12 pm Post subject: |
|
|
This is somehow related. I have a user (joanet) and I am the root in the same box. I ssh to the same external boxes, so I thought I could make a symbolic link and root could use joanet configuration:
Code: | # ln -s /home/joanet/.ssh /root/.ssh |
Code: | # ls -lisah /root
14417927 0 lrwxrwxrwx 1 root root 17 9 jun 19:46 .ssh -> /home/joanet/.ssh |
When I try to ssh from root:
# ssh mimosinnet
I get the following message:
Code: | Bad owner or permissions on /root/.ssh/config |
I understand the message: I am trying to ssh from root and the file owner is joanet:
Code: | # ls -lisah /root/.ssh/config
11337740 4,0K -rw------- 1 joanet joanet 359 9 jun 20:04 /root/.ssh/config |
This is my /root/.ssh/config
Code: | # cat /root/.ssh/config
Host mimosinnet
User mimosinnet
IdentityFile ~/.ssh/id_dsa
ForwardX11 yes
Compression yes
ForwardX11Trusted yes |
If I copy my joanet configuration to root, I have joanet ssh configuration working in root:
Code: | cp -r /home/joanet/.ssh . |
Is there a possibility to use symbolic links to not have to maintain two similar ssh configurations (joanet and root)?
Thanks! |
|
Back to top |
|
|
Dieter@be Guru
Joined: 03 Apr 2005 Posts: 314 Location: Wetteren, Belgium
|
Posted: Mon Jun 09, 2008 6:16 pm Post subject: |
|
|
afaik the owner of the ssh config must always be the user itself _________________ Nothing beats a ride on the Gentoo learning curve.
2 Gentoo Linux boxes - 2 Arch Linux boxes - Love all four
Say no to i386 binaries! -- Adopt an unanswered topic |
|
Back to top |
|
|
mimosinnet l33t
Joined: 10 Aug 2006 Posts: 717 Location: Barcelona, Spain
|
Posted: Mon Jun 09, 2008 7:44 pm Post subject: |
|
|
Dieter@be wrote: | afaik the owner of the ssh config must always be the user itself |
Good to know! This leads me towards finding another strategy. Thanks a lot for the answer! |
|
Back to top |
|
|
infinite1der n00b
Joined: 31 Jan 2006 Posts: 52 Location: Atlanta, GA
|
Posted: Mon Jun 09, 2008 9:12 pm Post subject: |
|
|
mimosinnet wrote: | Dieter@be wrote: | afaik the owner of the ssh config must always be the user itself |
Good to know! This leads me towards finding another strategy. Thanks a lot for the answer! |
See also sshd_config: StrictModes _________________ ----------------------
James A. Thornton
Atlanta, GA
How To Ask Questions the Smart Way |
|
Back to top |
|
|
mimosinnet l33t
Joined: 10 Aug 2006 Posts: 717 Location: Barcelona, Spain
|
Posted: Wed Jun 11, 2008 3:39 am Post subject: |
|
|
infinite1der wrote: | See also sshd_config: StrictModes |
Thanks very much for the tip. I have tried StrictModes with the abovementioned configuration (symbolic link of .ssh from root to user) and still unable to connect:
Code: | # grep StrictModes /etc/ssh/sshd_config
StrictModes no
# ssh mimosinnet
Bad owner or permissions on /root/.ssh/config |
These are the permissions of the config file:
Code: | 11339658 4,0K -rw------- 1 joanet joanet 466 11 jun 05:12 config |
Nevertheless, if I change the owner and permissions of the config file (it does not work if I make the file writtable for the group):
Code: | 11339658 4,0K -rw-r----- 1 root users 466 11 jun 05:12 config |
I am able to log from root and the user.
Great! Wonderful! Thanks a lot!
Update: Nevertheless, this happens independently of the value of StrictModes. |
|
Back to top |
|
|
|