M
M
MoyMirok2021-03-12 11:46:38
linux
MoyMirok, 2021-03-12 11:46:38

Why does it not show the name in the terminal using Putty, but when sudo requires the account password?

We were given the task to configure SSH access as on other machines. On other machines, when connected via Putty, the entire line with the login is visible. Key connection. And when I enter sudo su, it goes into root without additional passwords.

It turned out for me that after connecting, the login @ machine is not displayed, and when I enter sudo su it requires the account password, the connection is also by key.

Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-66-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Fri 12 Mar 2021 08:45:28 AM UTC

  System load:  0.0                Processes:               167
  Usage of /:   38.3% of 18.57GB   Users logged in:         0
  Memory usage: 9%                 IPv4 address for ens192: 192.168.111.200
  Swap usage:   0%

 * Introducing self-healing high availability clusters in MicroK8s.
   Simple, hardened, Kubernetes for production, from RaspberryPi to DC.

     https://microk8s.io/high-availability

5 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
Last login: Fri Mar 12 08:39:22 2021 from 192.168.111.24
$
$
$
$ sudo su
[sudo] password for user:
[email protected]:/home/user#


How to fix it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2021-03-12
@MoyMirok

write

sudo su -l

this will make sure that when the user changes, his profile will be loaded.
the password is not required by su, but by the sudo command - to execute sudo without a password - configure /etc/sudoers (edit with a command like sudo visudo)
You find there something like:
%sudo ALL=(ALL:ALL) ALL

change to:
%sudo ALL=(ALL:ALL) NOPASSWD:ALL

U
unseriously, 2021-03-12
@unseriously

The display логин@хостнеймat the beginning of the line is configured in the file ~./bashrc
. You can compare the contents of this file with the contents of the file on other machines and understand what needs to be added to make this inscription appear. It's also easy to google.
And about sudo without a password, this is also the first link in Google: https://losst.ru/otklyuchaem-parol-sudo-v-linux

S
Sand, 2021-03-12
@sand3001

The value of the environment variable "PS1" is responsible for how the shell prompt will look like on other machines - just copy the value.
You can view the value of PS1 like this: The value is set in the .bashrc file of the current user. On the subject of sudo: The settings for the sudo utility are in the . In order for sudo to work without a password, it is necessary for the current user or user group to register NOPASSWD in the sudoers file. IMHO it is best to make changes with the visudo utility
echo $PS1
grep PS1 ~/.bashrc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question