R, 5454 42 bytes
-12 bytes thanks to Jarko Dubbeldam
n=scan();m=diag(n)[,n:1];m[1,1]=m[n,n]=1;write(m,'',n)n]=1;m prints to stdout;returns a matrix; reads from stdin. creates an identity matrix diag(n), flips it top to bottom [,n:1], sets the top left and bottom right to 1, and then writes to console ('') with width n.