LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 02-17-2019, 03:09 AM   #1
chrisguk
LQ Newbie
 
Registered: Aug 2014
Posts: 14

Rep: Reputation: Disabled
CHROOT commands


Hi all,

I have created a chroot but I would like to let users be able to ssh to other devices from the chroot folder.

Is this possible, if so are there any suggestions or guides for this?
 
Old 02-17-2019, 03:35 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
What is the context? If they are coming into the chroot via SSH then all you need is for them to use -J on the client to specify the intermediate machine.

Code:
ssh -J user1@bastion.example.com user2@inside.example.com
That should work even if the ForceCommand directive is set for that account.
 
Old 02-17-2019, 03:51 AM   #3
chrisguk
LQ Newbie
 
Registered: Aug 2014
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
What is the context? If they are coming into the chroot via SSH then all you need is for them to use -J on the client to specify the intermediate machine.

Code:
ssh -J user1@bastion.example.com user2@inside.example.com
That should work even if the ForceCommand directive is set for that account.
In an ideal situation I would agree but we would like users to use this method of first logging in. When trying to invoke SSH I get this output:

Code:
-bash-4.4$ ssh root@host1
No user exists for uid 1000
 
Old 02-17-2019, 03:58 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Don't log in as root. Use a normal account.

Please write a bit more about what you are trying to do and how root has accidentally become involved. With the -J method they really are logging in but just passing through.
 
Old 02-17-2019, 04:18 AM   #5
chrisguk
LQ Newbie
 
Registered: Aug 2014
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
Don't log in as root. Use a normal account.

Please write a bit more about what you are trying to do and how root has accidentally become involved. With the -J method they really are logging in but just passing through.

Root was a mistake:

output for a user:

Code:
No user exists for uid 1000
So you log into the jump host, then you log into a computer from then in a privileged network for example:

Code:
ssh user@host1
 
Old 02-17-2019, 04:24 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Quote:
Originally Posted by chrisguk View Post
So you log into the jump host, then you log into a computer from then in a privileged network for example:
If the middle host is chrooted, then that is another reason to use the -J option. The main reason is that so you don't have to trust the middle machine at all, the connection is just streamed across it without decrypting.

Assuming that bastion.example.com chroots the accounts,

Code:
ssh user1@bastion.example.com "ssh user2@inside.example.com"
Then the password for inside.example.com is exposed on bastion as well as the data. Also, if the accounts on bastion are chrooted, then you'll have to have all the files and devices and logs present inside the chroot in order for the SSH client to work.

What aspect of your work flow makes you hesitant to use -J as normal?
 
Old 02-17-2019, 04:33 AM   #7
chrisguk
LQ Newbie
 
Registered: Aug 2014
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
If the middle host is chrooted, then that is another reason to use the -J option. The main reason is that so you don't have to trust the middle machine at all, the connection is just streamed across it without decrypting.

Assuming that bastion.example.com chroots the accounts,

Code:
ssh user1@bastion.example.com "ssh user2@inside.example.com"
Then the password for inside.example.com is exposed on bastion as well as the data. Also, if the accounts on bastion are chrooted, then you'll have to have all the files and devices and logs present inside the chroot in order for the SSH client to work.

What aspect of your work flow makes you hesitant to use -J as normal?
Okay yes I see your point, how would I implement this so that the user isnt actually allowed to log in to the bastion host and they can only use the "-J" switch on the command line?
 
Old 02-17-2019, 04:37 AM   #8
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
With the -J option, called ProxyJump in the client configuration, they really are logging in on the bastion host. It is just that they are not given a shell there and before any commands are run the stream is forwarded on to the next host in the chain. So it works even if everyone is chrooted on the bastion, say for chrooted SFTP there or just to avoid letting them having a shell on the bastion host.
 
  


Reply



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
Chroot in shell scripts: Ensuring that subsequent commands execute within the chroot Kenny_Strawn Programming 2 05-21-2012 12:25 PM
chroot to run hd-installed distro's programs from chroot in live distro? silencestone Linux - Software 0 10-12-2007 06:29 AM
sudo /usr/bin/chroot /home/chroot /bin/su - xxx| /bin/su: user xxx does not exist saavik Linux - General 3 07-04-2007 10:30 AM
mount command not working in chroot. and now chroot not working mohit.jain Linux From Scratch 5 07-14-2006 03:57 AM
to chroot or not to chroot complus Linux - Security 4 02-29-2004 04:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:12 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
Open Source Consulting | Domain Registration