bash - ssh script to connect to server -


i have basic script file.sh connects server

name=username routerip=172.21.200.37  echo "$name""@""$routerip" ssh "$name""@""$routerip" 

sample output:

$ ./file.sh username@172.21.200.37 username@172.21.200.37's password: 

what wondering how best handle password requested in script. should use expect? or there way. if password in script should encrypted security?

and maybe silly question but, there way connect server haveing username?

if care security, don't want embed password in script. , can't "encrypt" password, either, because script have know how decrypt it, , reading script see how did (and decryption key was, etc.).

if have script running on machine authorized log in machine b, way i've done set private ssh key on machine a, , put public key in user's authorized_keys file on machine b.

(in answer last question, no, there's no way sort of login without username.)


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -