linux 远程root登录失败,ssh以root用户远程登录失败

参考文献:

http://blog.csdn.net/lichangzai/article/details/39379153

http://blog.csdn.net/yasi_xi/article/details/8633189

通过secure crt远程ssh连接linux服务器,使用root用户直接访问,无法登陆成功。只能以普通用户登录,然后su root才能切换到 root账户。

解决方法:

1) 普通用户登录,然后su root切换到root账号,

2) vim /etc/ssh/sshd_config

3. 注释掉 #PermitRootLogin without-password,添加 PermitRootLogin yes

# Authentication:

LoginGraceTime 120

#PermitRootLogin without-password

PermitRootLogin yes

StrictModes yes

4. 重启 ssh  服务

root@ubuntu14:~# sudo service ssh restart

ssh stop/waiting

ssh start/running, process 1499

root@ubuntu14:~#

8c69f479e376ef9c01405f7f0056346e.png

Linux SSH 允许root用户远程登录和无密码登录

1. 允许root用户远程登录 修改ssh服务配置文件 sudo vi /etc/ssh/sshd_config调整PermitRootLogin参数值为yes,如下图: 2. 允许无密码登录同上,修 ...

禁止root用户远程登录

Linux修改ssh端口22 vi /etc/ssh/ssh_config vi /etc/ssh/sshd_config 然后修改为port 8888 以root身份service sshd res ...

linux下开启SSH,并且允许root用户远程登录,允许无密码登录

参考:http://blog.csdn.net/jia0511/article/details/8237698 1. 允许root用户远程登录 修改ssh服务配置文件 sudo vi /etc/ssh ...

Ubuntu-18.04 下修改root用户密码,安装SSH服务,允许root用户远程登录,安装vsftp服务器

修改root用户密码 打开终端,输入 sudo passwd root 指令: 安装SSH服务 ssh默认端口号是22,可以在/etc/ssh/sshd_config文件中修改 查看服务器否开启:ne ...

【Linux安全】防止 root 用户远程登录

防止 root 用户远程登录,在终端输入以下命令: vim /etc/ssh/sshd_config 修改如下行为:no PermitRootLogin no 如图所示:

root用户远程登录Ubuntu

安装了一台Ubuntu的服务器,由于大家都需要使用,因此创建了多个用户,多台windows机器用过Putty远程登录,但是默认情况下创建的用户都是普通用户,也就是说很多root用户能够使用的权限以及命 ...

Linux-解决putty无法直接使用root用户远程登录linux主机的问题

问题描述: 有时,在使用putty连接远程linux主机时会发现,无法直接使用root登录, 但是可以使用其他用户登录,然后切换至root用户. 解决办法: 1.修改配置文件 vi /etc/ssh/ ...

centos/linux 禁止root用户远程登录

注意:在禁止root等前要建立一个用户用来远程登录,否则退出后无法通过远程登录服务器. 编辑 /etc/ssh/sshd_config 文件 更改参数 PermitRootLogin yes 为 Pe ...

Mysql授权root用户远程登录

默认情况下Mysql的root用户不支持远程登录,使用以下命令授权   [Charles@localhost ~]$ mysql -uroot -p123 MariaDB [(none)]> u ...

随机推荐

Java中创建对象的5种方式

作为Java开发者,我们每天创建很多对象,但我们通常使用依赖管理系统,比如Spring去创建对象.然而这里有很多创建对象的方法,我们会在这篇文章中学到. Java中有5种创建对象的方式,下面给出它们的 ...

第16周界面设计PSP总结

计划:需1周完整完成 需求分析:作为一个观众,我希望能够了解每一场的比分结果,随时跟进比赛进程 生成设计文档:暂无 设计复审:暂无与组员进行设计复审 代码规范:Visual Studio2010 具体 ...

华为交换机netstream配置

1.配置交换机的流发送 [系统视图]ip netstream timeout active 100         流活跃时间 [系统视图]ip netstream timeout inactive ...

Struts2学习笔记-基本结构

一个普通的的web应用文件结构如下: 1. 最上层是应用名,区分大小写,在浏览器输入应用名的时候,必须与应用名的大小一样,例如:localhost:8080/HelloWorld 2. 在应用下,放有 ...

ytu 1910:字符统计(水题)

字符统计 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 421  Solved: 92[Submit][Status][Web Board] Descri ...

dataTabel转成dataview插入列后排序

if (!string.IsNullOrEmpty(strQuyu) && !string.IsNullOrEmpty(strZuhao)) { string[] param = { ...

查找(顺序表&有序表)

[1]查找概论 查找表是由同一类型是数据元素(或记录)构成的集合. 关键字是数据元素中某个数据项的值,又称为键值. 若此关键字可以唯一标识一个记录,则称此关键字为主关键字. 查找就是根据给定的某个值, ...

Asp.net Form登陆认证的回顾学习

asp.net网站中,我最常用的就是Form认证了,在实现登陆时,利用Form认证实现用户的访问权限,哪些页面是可以匿名登陆,哪些页面需要认证后才能访问,哪些页面不能访问等等权限.我还可在登陆时,使用 ...

[转]让程序在崩溃时体面的退出之CallStack

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
首先,我们需要创建一个新的Android Studio项目。在创建过程中,我们需要选择Empty Activity模板。 接下来,我们需要添加以下依赖项到项目中的build.gradle文件中: ``` implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'com.google.android.material:material:1.2.1' ``` 然后,我们需要创建一个新的布局文件activity_main.xml,其中包含一个EditText用于输入用户名和密码、一个Button用于提交和一个TextView用于显示验证结果。布局文件的代码如下: ``` <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center_horizontal"> <EditText android:id="@+id/editTextUsername" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Username"/> <EditText android:id="@+id/editTextPassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Password" android:inputType="textPassword"/> <Button android:id="@+id/buttonSubmit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Submit"/> <TextView android:id="@+id/textViewResult" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@android:color/holo_green_dark" android:textSize="18sp" android:textStyle="bold" android:gravity="center_horizontal"/> </LinearLayout> ``` 接下来,我们需要在MainActivity.java文件中编写代码来验证用户输入的用户名和密码。我们将使用SharedPreferences来存储用户信息。在onCreate()方法中添加以下代码: ``` // Get references to UI components EditText editTextUsername = findViewById(R.id.editTextUsername); EditText editTextPassword = findViewById(R.id.editTextPassword); Button buttonSubmit = findViewById(R.id.buttonSubmit); TextView textViewResult = findViewById(R.id.textViewResult); // Get shared preferences SharedPreferences preferences = getPreferences(MODE_PRIVATE); // Set click listener for submit button buttonSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String username = editTextUsername.getText().toString(); String password = editTextPassword.getText().toString(); // Check if username and password match stored values if (username.equals(preferences.getString("username", "")) && password.equals(preferences.getString("password", ""))) { textViewResult.setText("Login Successful"); textViewResult.setTextColor(Color.GREEN); } else { textViewResult.setText("Login Failed"); textViewResult.setTextColor(Color.RED); } } }); ``` 在这段代码中,我们首先获取了对EditText、Button和TextView的引用。然后,我们使用SharedPreferences获取存储在设备上的用户名和密码。接下来,我们在提交按钮上设置了一个单击监听器,当用户单击该按钮时,我们将获取EditText中输入的用户名和密码,然后将它们与SharedPreferences中存储的值进行比较。如果用户名和密码匹配,我们将在TextView中显示“登录成功”,否则我们将显示“登录失败”。 最后,在MainActivity.java文件中添加以下代码来保存用户信息: ``` // Save username and password to shared preferences SharedPreferences.Editor editor = preferences.edit(); editor.putString("username", "admin"); editor.putString("password", "password"); editor.apply(); ``` 在这段代码中,我们使用SharedPreferences.Editor对象将用户名和密码保存到SharedPreferences中。 这样,我们就完成了一个具有密码验证功能的远程用户登录程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值