Ask Your Question
0

How to get ssh access of CentOS instance without ssh-key? [closed]

asked 2016-08-01 11:12:22 -0500

zekken gravatar image

Hi, Is it possible to get the ssh access to CentOS instance without the ssh-key pair?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by mpetason
close date 2016-08-03 11:01:21.296730

2 answers

Sort by ยป oldest newest most voted
1

answered 2016-08-01 16:07:14 -0500

mpetason gravatar image

You can use user-data to set a password for the user. When launching an instance you'll paste this into the user-data:

#cloud-config
ssh_pwauth: True 
disable_root: false 
chpasswd:
  list: |
      user:password 
  expire: false

ssh_pwauth will turn on the ability to use password auth. disable_root will enable the root user. chpassword will setup a password for the user.

It's not recommended to use this regularly. You should use this for testing. Otherwise you should be using the user + ssh-key.

This will allow you to SSH with a password. It didn't work on Debian as the options were different in the sshd config, but should work with CentOS.

edit flag offensive delete link more

Comments

Thank you. That was very helpful. What is the way to do it while creating the image itself?

zekken gravatar imagezekken ( 2016-08-02 05:53:53 -0500 )edit
1

You'll want to check out the cloud-config examples with cloud-init:

https://cloudinit.readthedocs.io/en/l...

The docs go over the configuration options you can use.

mpetason gravatar imagempetason ( 2016-08-02 10:03:51 -0500 )edit

Thanks again :)

zekken gravatar imagezekken ( 2016-08-03 10:37:31 -0500 )edit

No problem. Good luck!

mpetason gravatar imagempetason ( 2016-08-03 11:00:55 -0500 )edit
1

answered 2016-08-01 21:00:22 -0500

Praveen N gravatar image

updated 2016-08-01 21:00:52 -0500

Hi, Another version user data you can use is :

#cloud-config
chpasswd:
  list: |
    user1:password1
    user2:password2
  expire: False
edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2016-08-01 11:12:22 -0500

Seen: 1,053 times

Last updated: Aug 01 '16