简体   繁体   中英

Ssh public key authentication without changing system files

I am changing different parameters like RSAAuthentication , PubkeyAuthentication and PasswordAuthentication ( sudo vim /etc/ssh/sshd_config ) to disable ssh password authentication to force ssh login via public key only.

The experiments are adversely affecting many users as they suddenly find "Connection refused" while trying to ssh to the server. I want to avoid these experiments. Is there any work around to enable public key authentication without touching system files like /etc/ssh/ssd_config ?

Sure. Set up an alternative configuration file, and run sshd on another port while you are experimenting:

cp sshd_config sshd_config_working
/usr/sbin/sshd -p 2222 -f sshd_config_working

Now you can connect with:

ssh -p 2222 user@localhost

And you can make as many changes as you want until you it working as desired. At that point, copy your _working config back to the main config file and restart sshd.

Alternatively, stop mucking about on a production server and set up a virtual machine or cotainer for testing, where you can modify the sshd configuration as much as you want without affecting anybody.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM