# [SOLVED] ssh to root when in bootstrap

## Joseph_sys

I bootstrap one of my boxes and running it in changeroot environment.

How to I ssh to root?

I've change in ssh/sshd_config "permit root login: yes"

it keep asking me for password but it does not recognize the password.Last edited by Joseph_sys on Mon Apr 23, 2012 4:22 pm; edited 1 time in total

----------

## EatMeerkats

Did you set the root password with "passwd" and start sshd with "/etc/init.d/sshd start"?

----------

## Joseph_sys

 *EatMeerkats wrote:*   

> Did you set the root password with "passwd" and start sshd with "/etc/init.d/sshd start"?

 

Yes, I did: 

```
ssh root@10.0.0.161

Password: 

PTY allocation request failed on channel 0
```

----------

## EatMeerkats

Hmm, sounds like /dev isn't mounted in the chroot… did you do something like "mount --rbind /dev /mnt/gentoo/dev" before you chrooted?

----------

## Joseph_sys

 *EatMeerkats wrote:*   

> Hmm, sounds like /dev isn't mounted in the chroot… did you do something like "mount --rbind /dev /mnt/gentoo/dev" before you chrooted?

 

I was following my notes when doing bootstrap:

```
boot strap gentoo liveCD (bootstrap) 

# swapon /dev/sda2

# mount -t ext3 /dev/sda3 /mnt/gentoo

# mount /dev/sda1 /mnt/gentoo/boot

# cd /mnt/gentoo

# mount -t proc none /mnt/gentoo/proc

# chroot /mnt/gentoo /bin/bash

# env-update

# source /etc/profile
```

----------

## BillWho

Joseph_sys.

Try this after mount -t proc none /mnt/gentoo/proc

```
mount -o bind /dev /mnt/gentoo/dev
```

----------

## Joseph_sys

 *BillWho wrote:*   

> Joseph_sys.
> 
> Try this after mount -t proc none /mnt/gentoo/proc
> 
> ```
> ...

 

it doesn't help :-/ still getting this:

```

PTY allocation request failed on channel 0
```

----------

## EatMeerkats

You need to use "mount --rbind /dev /mnt/gentoo/dev" so /dev/pts also gets mounted.

----------

## Joseph_sys

 *EatMeerkats wrote:*   

> You need to use "mount --rbind /dev /mnt/gentoo/dev" so /dev/pts also gets mounted.

 

Thank you, that was it!

So correct procedure for boot strap would be: 

```
# swapon /dev/sda2

# mount -t ext3 /dev/sda3 /mnt/gentoo

# mount /dev/sda1 /mnt/gentoo/boot

# cd /mnt/gentoo

# mount -t proc none /mnt/gentoo/proc

# mount -o bind /dev /mnt/gentoo/dev  (needed for ssh login)

# mount --rbind /dev /mnt/gentoo/dev (needed for ssh login)

# chroot /mnt/gentoo /bin/bash

# env-update

# source /etc/profile
```

----------

## EatMeerkats

Glad you got it working!  One quick note, though: "mount --rbind /dev /mnt/gentoo/dev" mounts /dev and its children, so you can skip the first "mount -o bind /dev /mnt/gentoo/dev".  :Smile: 

----------

## Joseph_sys

 *EatMeerkats wrote:*   

> Glad you got it working!  One quick note, though: "mount --rbind /dev /mnt/gentoo/dev" mounts /dev and its children, so you can skip the first "mount -o bind /dev /mnt/gentoo/dev". 

 

Noted, Thank you again.

----------

