João
João

Reputation: 187

Hide output of ssh command

I am trying to hide the output of this command:

string=$(su - user -c "ssh $L_NAME 'cat ~/.ssh/known_hosts'")

I've tried to do:

string=$(su - user -c "ssh $L_NAME 'cat ~/.ssh/known_hosts'") &> /dev/null

but it doesn't work. Does anyone know how to hide the output of the ssh command in this case?

Thanks

Upvotes: 1

Views: 3302

Answers (1)

SaintHax
SaintHax

Reputation: 1943

Try turning off STDERR in the command.

string=$(su - user -c "ssh $L_NAME 'cat ~/.ssh/known_hosts'" 2>&-) 

Upvotes: 1

Related Questions