To make apt suite work with a proxy :
1. gksudo gedit /etc/apt/apt.conf
2. Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).
3. Acquire::http::Proxy "http://yourproxyaddress:proxyport";
# to search a package
sudo apt-cache search countdown
# You want to autologin in machine B from A.
The underlying concept is put my public key in someone else's house.
1. first generate a pair of public/private key on host A:
[host A]$ ssh-keygen -t rsa
2. Put your newly generated key in host B:
[host B] $ emacs -nw .ssh/authorized_keys