I just want to run a python file on raspberry pi and use terminal code ssh. So, I don't want type password to do that. What should I do?
You can use public key authentication without protecting the private key with a password. On your management computer execute these commands:
mngmt ~$ mkdir -m 700 ~/.ssh mngmt ~$ ssh-keygen -N '' -f ~/.ssh/id_ecdsa -t ecdsa -b 521
This will give you a keypair
id_ecdsa as private key and
id_ecdsa.pub as public key in
~/.ssh/. Now on your client RasPi login as a user, for example pi, and create also:
rpi ~$ mkdir -m 700 /home/pi/.ssh
id_ecdsa.pub from the management computer to
home/pi/.ssh/authorized_keys on the client RasPi. Check with a simple ssh from your management computer if it works by executing
/bin/hostname on the client. That should return the hostname of the RasPi:
mngmt ~$ ssh pi@raspberrypi hostname raspberrypi mngmt ~$
This is a save authentication method as long as nobody else does get access to the private key file
id_ecdsa. Everyone owning this file have access to your clients so please pay attention to it.