How can I use scp in the Rescue Mode?

Issues related to configuring your network
Post Reply
MasaruKit
Posts: 8
Joined: 2020/08/07 01:51:17

How can I use scp in the Rescue Mode?

Post by MasaruKit » 2020/08/16 21:54:46

Hello.

My VPS hasn't been unable to start. I've read some articles on how to send files to other servers in the rescue mode.

I tried all the instructions, but I can't log in to another server, because the password for another server is rejected.

On the new server, in the /etc/ssh/sshd_config, I changed a "PasswordAuthentificatioon" from "no" to "yes". I can log in that server using a password from my mac but when I tried on the rescue mode, it says "Incorrect password" bot on scp and ssh.

How can I log in to the new server from the rescue mode?

Thank you for your assistance!

User avatar
TrevorH
Forum Moderator
Posts: 29493
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How can I use scp in the Rescue Mode?

Post by TrevorH » 2020/08/16 23:07:11

When you're in rescue mode, you are not using the files from your machine to boot up and run services. You are using the config file(s) that are built into the rescue image. You might need to create a user and set its password or key after it's booted up and then login as that user.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

MasaruKit
Posts: 8
Joined: 2020/08/07 01:51:17

Re: How can I use scp in the Rescue Mode?

Post by MasaruKit » 2020/08/16 23:33:51

Thank you, but I tried it.

What I'm wondering about is how to set up the network settings, including opening a port correctly.

Once I succeeded pinging to the new server and tried to connect using SSH, but couldn't log in because the password for the new server was refused.

That's the point I wonder.

User avatar
TrevorH
Forum Moderator
Posts: 29493
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How can I use scp in the Rescue Mode?

Post by TrevorH » 2020/08/17 08:42:30

Once I succeeded pinging to the new server and tried to connect using SSH, but couldn't log in because the password for the new server was refused.
Yes, and as I said, the /etc/passwd and /etc/shadow files that belong to your installed system are not the ones that the rescue option from the DVD uses. That uses the files that are present on the DVD image not the ones from your own system. So you would need to boot the iso, add a new user, set its password, start the firewall, amend its rules to allow external ssh connections, set up the network and start it, start sshd and then attempt to login with the newly created user.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

MasaruKit
Posts: 8
Joined: 2020/08/07 01:51:17

Re: How can I use scp in the Rescue Mode?

Post by MasaruKit » 2020/08/17 09:55:28

I'm sorry for my poor English that makes you confused.

I'm talking about login to the new server from ISO booted rescue mode.

The user foobar in the below is a user of example.com, isn't it?

Code: Select all

ssh foobar@example.com
I can't log in to the new server's user and password.

That's one of the problems. Another one is that ipconfig and route commands have nothing to do with ports. I'd like to know how to open the port. I wonder that I can't log in by ssh because of the password issue. So outgoing port 22 seems to be open, even I haven't done anything about ports.

Sorry again for my poor English.
TrevorH wrote:
2020/08/17 08:42:30
Yes, and as I said, the /etc/passwd and /etc/shadow files that belong to your installed system are not the ones that the rescue option from the DVD uses. That uses the files that are present on the DVD image not the ones from your own system. So you would need to boot the iso, add a new user, set its password, start the firewall, amend its rules to allow external ssh connections, set up the network and start it, start sshd and then attempt to login with the newly created user.

User avatar
TrevorH
Forum Moderator
Posts: 29493
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How can I use scp in the Rescue Mode?

Post by TrevorH » 2020/08/17 10:54:06

I'm talking about login to the new server from ISO booted rescue mode.
So am I. When you boot the iso in rescue mode, you are not using any of your system files. The system you boot does not know about any of the users that exist on your installed system which is why you cannot ssh/scp to it as those users. They do not exist. Which is why you need to add them to the running rescue system (and will need to do so every time you boot it as it's not persistent over reboots).

The system you boot from the rescue iso is as it ships from CentOS. It has no users other than root. It has no network settings set up. It has no firewall rules to allow access. You need to set all those up before you can access a rescue system remotely. You'd use the iptables command to manipulate firewall rules.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

MasaruKit
Posts: 8
Joined: 2020/08/07 01:51:17

Re: How can I use scp in the Rescue Mode?

Post by MasaruKit » 2020/08/18 04:58:21

My apologies.

After I boot from ISO, I used ifconfig and route for eth0 and succeeded.

Then I tried

Code: Select all

useradd admin
and

Code: Select all

passed admmin
, but it said “command not found”.
Next things I tried is as below

Code: Select all

userdel admin
useradd admin -p xxxxxxx
but I can't login with admin.

First I tried

Code: Select all

su admin
but again “command not found”, so I tried

Code: Select all

login admin
Then it said “Pane is dead”.

Would you please let me know how to create a user properly with password and how to switch to that user?

Thank you for help.
TrevorH wrote:
2020/08/17 10:54:06
So am I. When you boot the iso in rescue mode, you are not using any of your system files. The system you boot does not know about any of the users that exist on your installed system which is why you cannot ssh/scp to it as those users. They do not exist. Which is why you need to add them to the running rescue system (and will need to do so every time you boot it as it's not persistent over reboots).

The system you boot from the rescue iso is as it ships from CentOS. It has no users other than root. It has no network settings set up. It has no firewall rules to allow access. You need to set all those up before you can access a rescue system remotely. You'd use the iptables command to manipulate firewall rules.

tunk
Posts: 768
Joined: 2017/02/22 15:08:17

Re: How can I use scp in the Rescue Mode?

Post by tunk » 2020/08/18 09:44:33

It's "passwd", not "passed". And I guess that admmin (with two m's) is a typo?

MasaruKit
Posts: 8
Joined: 2020/08/07 01:51:17

Re: How can I use scp in the Rescue Mode?

Post by MasaruKit » 2020/08/18 09:58:12

I'm so sorry, both of them were typos.

Code: Select all

passwd admin
was the command I executed.
tunk wrote:
2020/08/18 09:44:33
It's "passwd", not "passed". And I guess that admmin (with two m's) is a typo?

Post Reply

Return to “CentOS 7 - Networking Support”