Can I SSH into a specific directory?
Well I knew I could run something on login, but I knew it would exit out straight after running. What I now remember is that I can run as much as I like on a remote server. You can just chain the commands together!
ssh user@server -t "cd /websites/website ; /bin/bash"
Now I can just tell fabric to do that and we're away. Simple.
I did say it wasn't anything to do with the Fabric but here's the new part of my fabric script too, based on the above:
def ssh():
''' SSH into the remote server at the correct directory '''
local('ssh -t -p%(port)s %(server)s "cd %(remote_dir)s ; /bin/bash"' % {
'server': server_host,
'port': server_port,
'remote_dir': remote_dir,
})
I symlink the same script around so the variables (server_host
, server_port
and remote_dir
) change from site to site.
Because Fabric can handle the outbound connection you can also just do this:
def ssh():
''' SSH into the remote server at the correct directory '''
run('cd %s ; /bin/bash' % remote_dir)
This does work but the output is prepended with a string from Fabric. This made the prompt over 80 chars long and while I've got tons of resolution, that's too much for me :)