apt sources.list ssh:// with custom port
I've setup my own repository which I want to use SSH as the protocol. I managed to get everything working with an SSH key using port 22.
Now, I would like to change the SSH port. I've already changed it on the SSH/repo server. Now I can't figure out how to change apt to use a custom port on the client computer.
My sources.list file line which worked over port 22:
deb ssh://[email protected]/home/user/repo lenny main contrib non-free
I've tried:
deb ssh://[email protected]:12345/home/user/repo lenny main contrib non-free
and it fails and actually says "failed connecting to port 22"
Can this be done? I've searched google for hours and I getting nothing but unrelated data. I've read the man pages. The man page for apt.conf specified that you can set the port this way for HTTP, but doesn't mention anything about ssh ports.
Also, a secondary question:
Can I somehow specify which SSH identity/key file to use for apt?
Thanks.
Solution 1:
I'd have expected the port setting to work — the behavior you describe sounds like a bug. But you don't need apt's cooperation here, you can use .ssh/config
instead. Create an alias for the apt repository machine and put the options you want:
Host my-apt-repository
HostName 1.1.1.1
User user
Port 12345
IdentityFile /path/to/private_key.id_rsa
Depending on your method for gaining root permission, you might need to put this in /root/.ssh/config
as well as ~/.ssh/config
.