大网数据广告活动
服务器运维问答

locked out of ssh and sftp and require new password

· 52CE 我爱测

I have tried to log into my Google Instance running "CIS CentOS Linux 7 Benchmark Level 1" and get the following message. It's asking for the current password which we don't have. Is there a way to gain access and reset things? I…

问题原文

原帖链接 · John K Bell · CC BY-SA 4.0

I have tried to log into my Google Instance running "CIS CentOS Linux 7 Benchmark Level 1" and get the following message.

It's asking for the current password which we don't have. Is there a way to gain access and reset things?

I'm currently locked out of the server for both SFTP and SSH. And for the record I'm using Cloud Shell to gain SSH access.

Thank you in advance

Welcome to Cloud Shell! Type "help" to get started.
Your Cloud Platform project in this session is set to xxxxxxxx.
Use “gcloud config set project [PROJECT_ID]” to change to a different project.
xxxxxx@cloudshell:~ (xxxxxx)$ gcloud compute --project "xxxxxx" ssh --zone "europe-west2-a" "xxxxxx"
Authorized uses only. All activity may be monitored and reported.
You are required to change your password immediately (password aged)
Last login: Mon Dec  3 17:07:52 2018 from 
xxxx.xxx.xxx.xx.bc.googleusercontent.com
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user xxxxx.
Changing password for xxxxx.
(current) UNIX password:

已采纳解答

原帖链接 · Alioua · CC BY-SA 4.0

This is your solution

Before check if your firewall is set correctly.

1 - Go to the VM instances page in Google Cloud Platform console.

2 - Click on the instance for which you want to add a startup script.

3 - Click the Edit button at the top of the page.

4 - Click on ‘Enable connecting to serial ports’

5 - Under Custom metadata, click Add item.

6 - Set 'Key' to 'startup-script' and set 'Value' to this script:

#! /bin/bash 
useradd -G sudo USERNAME 
echo 'USERNAME:PASSWORD' | chpasswd

7 - Click Save and then click RESET on the top of the page. You might need to wait for some time for the instance to reboot.

8 - Click on 'Connect to serial port' in the page. 9 - In the new window, you might need to wait a bit and press on Enter of your keyboard once; then, you should see the login prompt. 10.. Login using the USERNAME and PASSWORD you provided.

From there undo any change that you've done, if you have sshguard check if your IP is blocked.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-12-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。