以root身份无密码地SSH到远程系统 [英] passwordless ssh to remote system as root

查看:44
本文介绍了以root身份无密码地SSH到远程系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要ssh(以root身份)到远程服务器并执行一些root级操作.我将从没有root特权的本地服务器上切换.有了此选项,是否可以使用(rsa)键对远程系统执行无密码ssh?

I need to ssh (as root) to a remote server and perform some root level operations. I will be sshing from a local server where I don't have root privileges. Given this option, is it possible to perform passwordless ssh to remote system using (rsa) keys ?

本地和远程服务器运行linux.

Local and remote servers run linux.

顺便说一句,我在本地服务器上生成了密钥(ssh-keygen -t rsa).将公钥复制到远程服务器的.ssh/authorized_keys文件.但是仍然会提示输入密码.如果本地和远程用户名(非root用户)匹配,则相同的设置也可以正常工作.

BTW, I generated keys (ssh-keygen -t rsa) on the local server. Copied the public key to remote server's .ssh/authorized_keys file. However it still keeps prompting for password. The same setup works fine, if the local and remote username (non-root) matches.

推荐答案

1检查您的/etc/ssh/sshd_config文件是否具有"PermitRootLogin yes".

1 check that your /etc/ssh/sshd_config file have "PermitRootLogin yes".

2将以下Shell代码存储到nopasswd.sh中:

2 Store the following Shell code into nopasswd.sh:

#!/bin/sh

scp ~/.ssh/id_dsa.pub  $1@$2:~/
ssh $1@$2 "cat ~/id_dsa.pub  >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys; exit"

3通过以下步骤使用它:

3 Use it by these steps:

$ssh-keygen -t dsa
$ ./nopasswd.sh root REMOTE_HOST

这篇关于以root身份无密码地SSH到远程系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆