1 linux bash perl remote-access remote-server
我想在使用SSH登录远程linux服务器时自动输入密码.
我用了一个可执行的bash脚本
#! /bin/bash
ssh user@machine.remote.host
Run Code Online (Sandbox Code Playgroud)
但有没有办法自动输入密码?
ssh-keygen # generate a pair of RSA keys
scp ~/.ssh/id_rsa.pub user@machine.remote.host:id_rsa.tmp # copy the public key to remote host
ssh user@machine.remote.host # ssh to remote server, this time it requires password
cat id_rsa.tmp >> .ssh/authorized_keys # add the public key to authorized_keys
Run Code Online (Sandbox Code Playgroud)
然后你可以注销并登录而无需密码.