`
wang_2011_ying
  • 浏览: 148985 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

ssh without password

 
阅读更多
我们经常通过ssh访问服务器,每一次都要输入密码,为了避免这一环节,我们进行一下操作:
1、输入:
ssh-keygen -t rsa
这样你的~/.ssh/目录中就有两个新文件了,id_rsa和id_rsa.pub,分别为private/public key;
[eva@Eva ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/eva/.ssh/id_rsa): 
/home/eva/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/eva/.ssh/id_rsa.
Your public key has been saved in /home/eva/.ssh/id_rsa.pub.
The key fingerprint is:
f6:b1:f1:38:8c:41:31:c6:53:01:7f:7d:53:d9:4e:c7 eva@Eva
The key's randomart image is:
+--[ RSA 2048]----+
|       .=oo.   .+|
|       .o+   . .E|
|        ... . .+o|
|       .   .   .o|
|        S o      |
|       . = *     |
|        . * .    |
|           .     |
|                 |
+-----------------+
[eva@Eva ~]$ cd /home/eva/.ssh
[eva@Eva .ssh]$ ls
id_rsa  id_rsa.pub

注意:每次执行"ssh-keygen -t rsa"产生的私钥文件都会不同
2、把public key拷贝到服务器上,放在~/.ssh/目录中,首先登陆服务器,看看有没有该目录,没有就新建一个:
ssh sss@hpu.edu.cn
mkdir ~/.ssh

把刚才生成的public key文件拷贝到服务器上
scp ~/.ssh/id_rsa.pub sss@hpu.edu.cn:~/.ssh/

3、在服务器上把刚传过来的id_rsa.pub累加到authorized_keys文件末尾
ssh sss@hpu.edu.cn
cd ~/.ssh
cat id_rsa.pub >> authorized_keys
密钥不是人人可读的,所以要设置一下权限:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

4、每次登陆都需要输入sss@hpu.edu.cn是不是很烦,下面做一个alias就可以了:
echo 'alias sshsss="ssh sss@hpu.edu.cn"' >> .bashrc
source .bashrc
sshsss
分享到:
评论

相关推荐

    Re-SyncMysqlMasterSlaveReplication:如何重置(重新同步)MySQL 主从复制

    此工具必须在主服务器上运行ssh 访问两台服务器(主从) 使用 ssh 从主服务器到从属服务器的 ssh 访问(谷歌:ssh without password) 在这一点上有一些帮助。 使用 ssh 以您要使用的帐户名登录到您的服务器。 提示...

    SSH无密码登录配置(主要针对Hadoop配置)

    PermitRootLogin without-password ``` 如果允许root用户无密码登录,需设置`PermitRootLogin`为`without-password`。但出于安全考虑,一般不推荐直接用root用户进行SSH登录。 **五、重启SSH服务** 修改配置后,...

    Hadoop ubuntu 9.10 下的 SSH 免登陆

    4. **配置SSH**:编辑`/etc/ssh/sshd_config`文件,确保`PermitRootLogin`设置为`without-password`或`no`,以禁止root用户通过密码登录。同时,确认`PubkeyAuthentication`设置为`yes`,启用公钥认证。 5. **重启...

    ssh服务安装软件及其操作步骤.zip

    PermitRootLogin without-password PasswordAuthentication no PubkeyAuthentication yes ``` 接着,将公钥复制到嵌入式设备上,以实现无密码登录: ```bash ssh-copy-id -i ~/.ssh/id_rsa.pub root@device_ip ```...

    批量配置服务器ssh免密rsa登录

    6. **其他安全实践**:启用SSH的严格模式(`PubkeyAuthentication yes`和`PermitRootLogin without-password`),禁止密码登录,只允许公钥认证,以及设置防火墙规则限制SSH的访问端口和来源IP,都是增强SSH安全性的...

    SSH移植到android系统步骤.doc

    `PermitRootLogin without-password` `RSAAuthentication yes` `PubkeyAuthentication yes` `PasswordAuthentication no` 这样,我们就可以使用密钥登录Android系统了。 通过这篇文章,我们可以了解如何将OpenSSH...

    Ubuntu 16.04远程登录服务器ssh的安装和配置.pdf

    在 /etc/ssh/sshd_config 文件中,需要修改 Authentication 部分,注释掉“PermitRootLogin without-password”并添加“PermitRootLogin yes”: sudo vi /etc/ssh/sshd_config Authentication #PermitRootLogin ...

    openssh-server -Ubuntu18.04远程服务离线安装包

    依次运行下面命令进行安装: sudo dpkg -i openssh-client_1%3a7.6p1-4ubuntu0.6_amd64.deb sudo dpkg -i ncurses-term_6.1-1ubuntu1.18.04_all.deb ... 删除permitRootLogin后面的without-password后改为yes

    FreeBSD 8.0 配置密钥登录

    - **PermitRootLogin**: 设置为`without-password`,表示root用户可以使用密钥认证登录,但不能使用密码登录。 下面是修改后的部分配置示例: ``` Protocol 2 RSAAuthentication yes PubkeyAuthentication ...

    配置Docker容器ssh服务端实现远程ssh登录

    #此步骤主要目的是修改sshd_config配置文件,把配置文件中的”PermitRootLogin without-password”加一个”#”号,把它注释掉,再增加一句”PermitRootLogin yes”,参考:https://www.jianshu.com/p/adda91b7c1d2 ...

    openstack【juno】入门 【准备篇】一: Ubuntu14.04远程连接(ssh安装)

    在文件中,找到`PermitRootLogin without-password`这一行,添加一个`#`号,将其注释掉。接着,在文件末尾添加一行`PermitRootLogin yes`。这允许root用户使用密码登录,但为了安全,通常建议使用密钥对认证而非密码...

    linux下ssh服务器端的简单配置定义.pdf

    4. `PermitRootLogin without-password`: 允许root用户以无密码方式登录,这在生产环境中通常是不推荐的,因为它增加了被恶意攻击的风险。 5. `PasswordAuthentication yes`: 开启密码验证,允许用户通过密码登录。...

    ubuntu16.04服务器配置ssh免密码登录

    PermitRootLogin without-password ``` 修改后,记得保存并重启SSH服务以应用更改。 ```bash sudo service ssh restart ``` ### SSH简写技巧 创建一个`~/.ssh/config`文件,可以定义别名和配置,以简化SSH...

    ubuntu16.04安装ssh服务并实现远程访问的方法

    找到`PermitRootLogin`行,可能注释掉了或者设置为`without-password`,将其改为`yes`,如下所示: ``` PermitRootLogin yes ``` 保存并关闭文件后,需要重启SSH服务以应用新的配置: ```bash sudo systemctl ...

    How to use SFTP

    The topic How to use SFTP (with client validation - password authentication) discusses the simplest form of client authentication, via password. In public key authentication, SSH clients and ...

    ubuntu开启SSH服务远程登录操作的实现

    例如,若要禁止root用户密码登录,可以注释掉`PermitRootLogin without-password`行,并添加`PermitRootLogin no`。 6. **连接SSH**: 使用SSH命令进行远程登录,格式为`ssh username@hostname`,其中`username`是...

    谷歌云服务器设置多服务器间ssh免登录连接(ubantu 18.04)

    PermitRootLogin without-password 改为 PermitRootLogin yes 重启ssh服务:sudo service sshd restart 密码设置:sudo passwd user-name 然后设置各个主机的映射 sudo vim /etc/hosts 192.168.128.128 Master 192....

    设置ssh无密码登录linux服务器的方法

    通常,`RSAAuthentication`和`PubkeyAuthentication`应设为`yes`,`PermitRootLogin`应设为`yes`或`without-password`。不过,允许root用户直接SSH登录可能存在安全隐患,建议为普通用户创建账户并使用sudo权限。 ...

    openssh-7.1p2.tar.gz

    prohibit-password/without-password that could, depending on compile-time configuration, permit password authentication to root while preventing other forms of authentication. This problem was ...

    Centos7-openssh8.6p1升级手册.docx

    sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config ``` 如果启用了SELinux,需要临时关闭或修改其配置以允许OpenSSH运行: ```bash sed -i 's/SELINUX=enforcing/...

Global site tag (gtag.js) - Google Analytics