Поменять пароль linux ssh

Смена номера порта для SSH

По умолчанию для подключения к серверу Линукс используется протокол SSH и 22 порт.
Иногда, для безопасности или по каким то другим требованиям, пользователю нужно изменить порт на другой.

Смена номера порта для подключения по SSH

Для начала посмотрим какие порты свободны, чтобы случайно не взять занятый.
# netstat -tupln | grep LISTEN

Определившись с номером нового порта и удостоверившись что он не занят нужно открыть файл по адресу /etc/ssh/sshd_config
Это можно сделать с помощью FTP-клиента (WinScp, Filezilla и т.д.) или через один из тестовых редактор линукса vi или nano.
Для редактора vi:
# vi /etc/ssh/sshd_config
Для редактора nano:
# nano /etc/ssh/sshd_config

В открытом файле sshd_config находим строку «Port 22» и меняем номер порта на желаемый.

Теперь сохраняем файл.
Для редактора vi:
# :wq
Для редактора nano:
# CTRL+O

Чтобы изменения применились, необходимо перезагрузить SSH-сервер.
Это можно сделать командой:
# /etc/init.d/ssh restart
или
# /etc/init.d/sshd restart

Смена пароля для пользователя root

Заходим через SSH под root пользователем и вводим команду:
#passwd root

Нажимаем Enter, затем два раза вводим новый пароль и опять нажимаем Enter.
Готово, новый root-пароля задан.

Источник

Сменить пароль root-пользователя

Разберём, как можно самостоятельно сменить пароль от root-пользователя VPS у в панели управления.

Для этого нам потребуется зайти в панель оплаты услуг, логин это почтовый ящик регистрации и пароль который был сгенерирован при регистрации, если пароль не подходит Вы всегда можете воспользоваться восстановлением пароля, нажмите на кнопку «Восстановить пароль».

1. Смена пароля в старом интерфейсе

Смена пароля root-пользователя через старый ISP

Для смены пароля в старом интерфейсе зайдите в панели оплаты услуг перейдите в раздел «Товары/Услуги» — «Серверы VPS/VDS», выберите услугу VPS-сервера, в верхней панели нажмите на кнопку «Сменить пароль».

Смена пароля root-пользователя через старый ISP

Далее перед Вами появится окно для смены пароля, есть возможность указать свой пароль или нажать на иконку с игральными кубиками для автоматической генерации пароля.

Новый пароль добавлен в поля, нажмите на кнопку «ОК». Ожидайте смены пароля, в это время сервер будет автоматически перезагружен.

Смена пароля root-пользователя через старый ISP

Чтобы узнать данные для доступа к VPS-серверу, в том же разделе выберите услугу хостинга, в верхней панели нажмите на кнопку «Инструкция».

2. Смена пароля в новом интерфейсе

Смена пароля root-пользователя через новый ISP

Для смены пароля в новом интерфейсе перейдите в раздел «Все услуги» — «Серверы VPS/VDS».

Смена пароля root-пользователя через новый ISP

В поле с услугой VPS-сервера нажмите на вертикальное многоточие и из выпадающего меню выберите пункт «Информация».

Смена пароля root-пользователя через новый ISP

Перед Вами появится окно с данными по VPS-серверу, необходимо перейти в пункт «Доступ root», и в поле с паролем нажмите на «Изменить».

Читайте также:  Открыть скрытые папки linux

Смена пароля root-пользователя через новый ISP

Аналогично, как и в старом интерфейсе Вы можете ввести свой пароль или нажать на кнопку «Генерировать». Как только Вы указали новый пароль, нажмите на кнопку «Изменить».

Смена пароля root-пользователя через новый ISP

Для просмотра данных для доступа перейдите в раздел «Все услуги» — «Серверы VPS/VDS», в поле с услугой VPS-сервера нажмите на вертикальное многоточие, из выпадающего меню выберите пункт «Инструкция».

3. Смена пароля при подключение по SSH.

Для смены пароля подключаемся к серверу выполняя данную команду:
ssh root@IP-адрес_сервера

Далее у нас запросят пароль для подключения, копируем и вводим пароль.

Смена пароля root-пользователя при подключении по SSH

Чтобы сменить пароль вводим данную команду:
passwd root

Далее Вам необходимо будет указать новый пароль и продублировать его, применяем изменения. Закрываем соединение по SSH комбинацией клавиш CTRL+D. Повторно подключаемся к VPS-серверу уже с новыми данными:
ssh root@IP-адрес_сервера

При использование данного способа, в инструкции к услуге VPS-сервера пароль не измениться, а останется последний выставленный пароль, поэтому после смены пароля данным способом рекомендуем сохранить пароль у себя на ПК.

МИР Visa MasterCard СБП QIWI Wallet Безналичный платеж

  • Услуги
  • Хостинг сайтов
  • Домены
  • Конструктор
  • Linux VPS / Windows VPS
  • Выделенные серверы
  • SSL сертификаты
  • Лечение от вирусов
  • Клиентам
  • Контакты
  • О компании
  • Акции
  • Оборудование
  • Партнерская программа
  • Поддержка
  • Способы оплаты
  • Регламент
  • Документы
  • Справка

Источник

Script to change password on linux servers over ssh

We have a number of Red Hat linux servers in our IT environment. I am being asked by my team members to write a script (preferably shell script) to change a user’s password on each one of those in a single go, using SSH. I have tried to find a solution but many of the scripts I found are using Expect. We do not have Expect installed on our servers and the system admins have refused to let us install it. Also, the users do not have root access so passwd —stdin or chpasswd cannot be used. Is there any way a script can be written so that a user can run it and change the password of only his own user on all the servers in a list?

17 Answers 17

The remote machine(s) do not need expect installed. You can install expect on a local workstation or VM (virtualbox) or whichever *nix box, and write a wrapper that calls this .ex (expect) script (there may be small changes from distro to distro, this tested on CentOS 5/6):

#!/usr/bin/expect -f # wrapper to make passwd(1) be non-interactive # username is passed as 1st arg, passwd as 2nd set username [lindex $argv 0] set password [lindex $argv 1] set serverid [lindex $argv 2] set newpassword [lindex $argv 3] spawn ssh $serverid passwd expect "assword:" send "$password\r" expect "UNIX password:" send "$password\r" expect "password:" send "$newpassword\r" expect "password:" send "$newpassword\r" expect eof 

Using this code, you would want to make this code something like ./passwdWrapper and then in your bash file add ./passwdWrap $user $password $server $newpassword

Читайте также:  Драйвер вай фай линукс минт

If it’s the first time you connect to this server you might be prompted to verify the fingerprint, to get around this update line 10 from spawn ssh $serverid passwd to spawn ssh -o «StrictHostKeyChecking no» $serverid passwd

You do not need root access to use passwd .

This shoud work just fine.

Thank you Dennis, as per your post, passwd works well once the user is logged on the desired server. However, I have a list of servers stored in a file servers.txt and I would like to run a script, provide old password and new password once, and then the script should change my password on all the servers in that list. Any ideas with that?

Thank you Dennis, I have made an edit to my question showing what I have tried. It is still not there yet, but it’s a good start. Thank you.. 🙂

@CristianCiupitu: The questions mentions that passwd —stdin can’t be used because the users don’t have root access. My answer explains that this premise is false; root access is not required.

You should try pssh (parallel ssh at the same time).

You can run this command on any distro like an Android device, a laptop, your desktop. You just need to install it on client side and just have ssh as server side. I see no problem 😉 You can iterate too for simple need with a for loop : for i in foo bar base; do ssh «$i» «command line»; done

If you feel that reply is usefull, you can «upvote» it. If it fits your needs, you should «accept» the reply, that’s how stackoverflow works.

Building on squashbuff’s example, I tried the following, which worked well for me:

#!/bin/bash for server in `cat hostlist`; do echo $server; ssh username@$server 'passwd <<EOF old_password new_password new_password EOF'; done

Security wise, Could be improved to take input without echoing to the screen OR saving the plaintext to disk.

echo "name:password" | chpasswd 

Another possibility: change it manually on one server. Get the encrypted password out of /etc/shadow. Now, do something like this:

for host in $HOST_LIST; do ssh $host "passwd -p 'encrypted_passwd' user" done 

Of course, ‘encrypted_passwd» is what you got out of /etc/shadow where you manually changed the password. And $HOST_LIST is a list of hosts where you want the password changed. That could be created simply with:

export HOST_LIST="server1 server2 server15 server67" 

Or perhaps with a file (as others have suggested):

export HOST_LIST=`cat host_list.txt` 

Where the file «host_list.txt» has a list of all the systems where you want the password changed.

Edit: if your version of passwd doesn’t support the -p option, you might have the ‘usermod’ program available. The example above remains the same, simply replace ‘passwd’ with ‘usermod’.

Читайте также:  Виртуальная машина ставим линукс

Furthermore, you might consider the useful tool pdsh, which would simplify the above example to something like this:

echo $HOST_LIST | pdsh -Rssh -w- "usermod -p 'encrypted_passwd' user" 

One last «gotcha» to look out for: the encrypted password likely contains the dollar sign character (‘$’) as a field separator. You’ll probably have to escape those in your for loop or pdsh command (i.e. «$» becomes «\$»).

Источник

How to Change SSH Password? (5 Simple Steps)

How to Change SSH Password from the Cli?

Follow this article to change SSH password in simple steps.

First of all, enable the SSH with this command:

Change SSH Passsword

Login to your server with SSH

Type this command to change the password.

Change SSH Passsword

The terminal will ask for a password.

Press ‘Enter’ after typing a strong password.

Your password is set.

Change SSH Passsword

What is SSH?

What is SSH?

SSH is known as Secure Shell or Secure Socket Shell.

Basically, it is a secure network protocol. SSH helps admins in taking the access to the servers in a secure environment. It sends the command in cryptographic form.

Before the SSH, Telnet was the popular Application Protocol. But it was using the plain text to convey the commands. Overall, it was not a secure protocol.

Therefore, SSH became popular after the release.

The difference between SSH and Telnet is sort of similar to HTTP vs HTTPS.

According to RFC 4252, the Secure Shell Protocol (SSH) is a protocol for secure remote login and other secure network services over an insecure network.

The set of tools makes the communication secure and cryptic.

There are three sets of utilities: slogin, ssh, scp.

Functions of SSH

After enabling the SSH, you can use various fucntions.

Few of them are:

  • Providing access to a network system or devices that are SSH enabled.
  • Making transferring of files secure and interactive
  • File transfer on automation
  • Secured commands execution
  • Securing the management of network infrastructure components.

SSH is also used in various scripts that enable the access of data.

History of SSH

The first stable version of SSH was appeared in 1995. After Tatu Ylonen designed the original SSH protocol in 1995, he published it as open source.

The first version is already outdated and insecure to use. But with various improvement and updates, SSH is one of the most used application protocol in the industry.

Internet Engineering Task Force (IETF) iadopted the current version of Secure Shell protocols, SSH-2 as a Standards Track specification.

In Conclusion

SSH is a secure application network protocol.

But changing the passwords at fix interval of time is a good idea.

1 change ssh password

In this article, I told you how to change the SSH password.

I hope you can change SSH password now.

If any doubts, leave the comments below.

Источник

Оцените статью
Adblock
detector